Gossamer Forum
Home : General : Databases and SQL :

SQL Syntax

Quote Reply
SQL Syntax
Hi All, ive done a structure dump from another database, but when i try and create the following in another database i get an error



You have an error in your SQL syntax near '\'0\' NOT NULL auto_increment,
first_name varchar(50),
surname varchar(5' at line 2


Could some one tell me why??

Code:
CREATE TABLE users (
id int(11) DEFAULT '0' NOT NULL auto_increment,
first_name varchar(50),
surname varchar(50),
address1 varchar(100),
address2 varchar(100),
town varchar(100),
county varchar(100),
p_code varchar(100),
country varchar(100),
h_tel varchar(100),
m_prefix varchar(100),
m_tel varchar(100),
email varchar(100),
username varchar(100),
password varchar(100),
signup_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
last_login datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
activated tinyint(4) DEFAULT '0' NOT NULL,
userlevel tinyint(4) DEFAULT '0' NOT NULL,
randc int(11),
PRIMARY KEY (id)
);
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!

Last edited by:

mdj1: Aug 13, 2003, 11:02 PM
Quote Reply
Re: [mdj1] SQL Syntax In reply to
I just executed the query without an error - 3.23.49-nt

Last edited by:

Paul: Aug 14, 2003, 2:36 AM
Quote Reply
Re: [mdj1] SQL Syntax In reply to
The following line:

id int(11) DEFAULT '0' NOT NULL auto_increment,

should be:


id int(11) NOT NULL auto_increment,


For auto-incremented fields/primary, you should not set a default for the field.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] SQL Syntax In reply to
Doh!!! I cant believe I missed that!



Thanks
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!