Can anyone please tell me what is wrong with this query.
This is my code:
And I get this error:
could not UPDATE cb_temp:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key (cb_id) ADD INDEX id (id), ADD INDEX start_date (start_date)' at line 2
The columns that I am trying to index id and start_date already exist in the table , but cb_id does not exist, I want to create it and have it filled with consecutive numbers.
Thanks for any help.
.
This is my code:
Code:
$sql = "ALTER TABLE `cb_temp`
ADD cb_id int(8) auto_increment, primary key (cb_id)
ADD INDEX id (id),
ADD INDEX start_date (start_date)";
$result = mysql_query($sql)
or die("could not UPDATE cb_temp". mysql_error());
could not UPDATE cb_temp:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key (cb_id) ADD INDEX id (id), ADD INDEX start_date (start_date)' at line 2
The columns that I am trying to index id and start_date already exist in the table , but cb_id does not exist, I want to create it and have it filled with consecutive numbers.
Thanks for any help.
.
Comment