Jump to content

alter table not working for some versions of mysql


kalster
Go to solution Solved by requinix,

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;
";
Link to comment
Share on other sites

  • Solution

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
";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.