PDA

View Full Version : SQL error check


Hobbes
05-10-2003, 11:17 PM
i was told to run this query

CREATE TABLE `useralias` ( `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL, `alias` VARCHAR(50) NOT NULL );

and I got

Database error in vBulletin Control Panel 2.2.6:

Invalid SQL: CREATE TABLE `useralias` ( `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL, `alias` VARCHAR(50) NOT NULL );
mysql error: You have an error in your SQL syntax near '; ' at line 1

mysql error number: 1064

I was wondering if anyone could tell me what's wrong with the query or something, it would be of great help =)

filburt1
05-10-2003, 11:22 PM
I think the DEFAULT clause must come after NOT NULL.

Hobbes
05-10-2003, 11:26 PM
example? sorry, I am very illiterate :(

filburt1
05-10-2003, 11:35 PM
NOT NULL DEFAULT 0 rather than DEFAULT 0 NOT NULL.

Hobbes
05-10-2003, 11:42 PM
ok i ran

CREATE TABLE `useralias` ( `userid` INT(10) UNSIGNED NOT NULL DEFAULT '0' , `alias` VARCHAR(50) NOT NULL );

and got...
Database error in vBulletin Control Panel 2.2.6:

Invalid SQL: CREATE TABLE `useralias` ( `userid` INT(10) UNSIGNED NOT NULL DEFAULT '0' , `alias` VARCHAR(50) NOT NULL );
mysql error: You have an error in your SQL syntax near '; ' at line 1

mysql error number: 1064

filburt1
05-10-2003, 11:48 PM
You didn't specify a default for the second column (alias).

Hobbes
05-10-2003, 11:55 PM
alright im really illiterate, please forgive me filburt1....least i'm not PMing you XD!

anyway...

i ran...

CREATE TABLE `useralias` ( `userid` INT(10) UNSIGNED NOT NULL DEFAULT '0' , `alias` VARCHAR(50) NOT NULL DEFAULT '0' );

and got...

Database error in vBulletin Control Panel 2.2.6:

Invalid SQL: CREATE TABLE `useralias` ( `userid` INT(10) UNSIGNED NOT NULL DEFAULT '0' , `alias` VARCHAR(50) NOT NULL DEFAULT '0' );
mysql error: You have an error in your SQL syntax near '; ' at line 1

mysql error number: 1064

*dies*


also, i tried putting the DEFAULT 0 befor NOT NULL in both instances and still no luck :(:bunny:

Xenon
05-11-2003, 10:39 AM
remove the ; at the end of the query

Hobbes
05-11-2003, 06:42 PM
jeeze i am an idiot...thanks xenon :)

Xenon
05-11-2003, 06:43 PM
*gg*

you're welcome ;)