Average Joe
Average Joe

Reputation: 4601

putting comments in the middle of a createtable statement

I got this create table statement;

$sql = "CREATE TABLE TermsFinal(
    `seed`          INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `source`        varchar(100),
    `old_term`      varchar(255),
    `new_term`      varchar(100),
    `same_as`       varchar(100),
    `last_access`   datetime)";

Is there a way to put comments into this statement to the same effect as follows?

$sql = "CREATE TABLE TermsFinal(
    `seed`          INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `source`        varchar(100),    //sample value services.media
    `old_term`      varchar(255),    // something like  "services.media>category:perspective"
    `new_term`      varchar(100),    // something like "opinion"
    `same_as`       varchar(100),    // the seed id of another record or another  "old_term" from this table 
    `last_update`   datetime)";      // when the last update took place

Upvotes: 2

Views: 77

Answers (2)

user1387316
user1387316

Reputation:

you would have to use sql comments in the lines your still in the sql statement. for mysql this would be:

$sql = "CREATE TABLE TermsFinal(
`seed`          INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`source`        varchar(100),    /* sample value services.media */
`old_term`      varchar(255),    /* something like  "services.media>category:perspective" */
`new_term`      varchar(100),    /* something like "opinion" */
`same_as`       varchar(100),    /* the seed id of another record or another  "old_term" from this table */
`last_update`   datetime)";      // when the last update took place

Upvotes: 1

Andrey Gurinov
Andrey Gurinov

Reputation: 2885

Try following SQL comment syntax, but be careful with " in your text

$sql = "CREATE TABLE TermsFinal( 
    `seed`          INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    `source`        varchar(100),    -- sample value services.media 
    `old_term`      varchar(255),    -- something like  "services.media>category:perspective" 
    `new_term`      varchar(100),    -- something like "opinion" 
    `same_as`       varchar(100),    -- the seed id of another record or another  "old_term" from this table  
    `last_update`   datetime)";      // when the last update took place 

Read more...

Upvotes: 2

Related Questions