I am new here, so please go easy on me :shifty:
I am reading the book [ Build Your Own Database Driven Website Using PHP and MySQL 4th Edition ].
I am now on Chapter 2 [ Introducing MySQL ] aaand I have a Question
Does the order of this matter ?
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
I mean can this also work ?
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL
I would greatly appreciate any help.
looks like it
One thing cleared
Ok I think I have found the problem.
I was doing this:
id NOT NULL AUTO_INCREMENT INT PRIMARY KEY
But it seems that at least th Data Type MUST Follow the name of the field .. then the order of the others doesn't matter !! I say that because this worked:
id INT AUTO_INCREMENT PRIMARY KEY NOT NULL
Am I right ?
what happened when you tested it?
i don't think so, because it worked fine when i tested it
CREATE TABLE test_foo
( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, foo VARCHAR(99)
CREATE TABLE test_bar
( id INT PRIMARY KEY AUTO_INCREMENT NOT NULL
, bar VARCHAR(99)
you might have something else in your CREATE TABLE statement that we can't see that's causing the error
OK I have now tested it and I get the following:
Error 1064 (42000): 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 'NOT NULL AUTO_INCREMENT PRIMARY KEY INT, name TEXT, address TEXT) DEFAULT CHARAC' at line 2
Does that mean It has a specific order that must be followed ? :injured:
Hehe I was scared to test it, I thought If I did > it will destroy all the work that I had done up to that point.