Jump to content

alter table not working for some versions of mysql


kalster

Recommended Posts

I have noticed that some versions of mysql, the code below needs a ";" at the end of each line while other versions work with a "," and the end of each line. At what version of mysql did that change take place?

$mySQL = "alter table users 
add `username` varchar(20) not null;
add `location` varchar(100) not null;
";

That there is not a valid query. What was probably happening was the "username" column was added and everything after the semicolon was ignored.

 

Use a comma. A comma. You would know that if you bothered to learn SQL.

$mySQL = "alter table users 
add `username` varchar(20) not null,
add `location` varchar(100) not null
";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.