Page 1 of 1

#1064 - You have an error in your SQL syntax

Posted: Wed Jul 20, 2005 10:38 am
by nutkenz
I just started with MySQL a couple of weeks. I bought a book, read everything I thought I might need one day and started with my first database:

SQL-query:

Code: Select all

CREATE TABLE armor(
armor_key INT NOT NULL AUTO_INCREMENT UNSIGNED,
armor_server VARCHAR( 10 ) NOT NULL ,
armor_name VARCHAR( 250 ) NOT NULL ,
armor_level SMALLINT NOT NULL UNSIGNED,
covers TINYINT NOT NULL UNSIGNED,
craft TINYINT NOT NULL UNSIGNED,
tinks TINYINT UNSIGNED DEFAULT '0',
value SMALLINT NOT NULL UNSIGNED,
wield_meleed SMALLINT UNSIGNED,
wield_missiled SMALLINT UNSIGNED,
wield_magicd SMALLINT UNSIGNED,
act_meleed SMALLINT UNSIGNED,
act_missiled SMALLINT UNSIGNED,
act_magicd SMALLINT UNSIGNED,
act_rank SMALLINT UNSIGNED,
act_race SMALLINT UNSIGNED,
act_arcane SMALLINT UNSIGNED,
imbue TINYINT UNSIGNED,
date_posted DATETIME NOT NULL ,
date_ends DATETIME NOT NULL ,
armor_status CHAR DEFAULT '0',
seller INT NOT NULL ,
high_bidder INT NOT NULL ,
low_bidder INT NOT NULL ,
bids_total INT UNSIGNED DEFAULT '0',
low_bid SMALLINT UNSIGNED DEFAULT '0',
high_bid SMALLINT UNSIGNED DEFAULT '0',
spells VARCHAR( 250 ) ,
major1 VARCHAR( 250 ) ,
major2 VARCHAR( 250 ) ,
major3 VARCHAR( 250 ) ,
major4 VARCHAR( 250 ) ,
minor1 VARCHAR( 250 ) ,
minor2 VARCHAR( 250 ) ,
minor3 VARCHAR( 250 ) ,
minor4 VARCHAR( 250 ) ,
)
MySQL said: Documentation
#1064 - 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 'UNSIGNED,
armor_server VARCHAR(10) NOT NULL ,
armor_name
I read it over and over again, but I don't see why this shouldn't work. It's probably someting very simple but I just don't see the problem... Any help is appreciated.

Posted: Wed Jul 20, 2005 12:33 pm
by timvw
Everything (and more) than you need to know: http://dev.mysql.com/doc/mysql/en/create-table.html


(armor_key INT UNSIGNED NOT NULL AUTO_INCREMENT)

Posted: Wed Jul 20, 2005 1:31 pm
by nutkenz
Ah, een Leuvenaar :)

Ik zal het even proberen met die volgorde...

Posted: Wed Jul 20, 2005 1:38 pm
by nutkenz
w00t! :)

Your SQL-query has been executed successfully (Query took 0.0045 sec)
SQL-query:
CREATE TABLE armor(
armor_key INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
armor_server VARCHAR( 10 ) NOT NULL ,
armor_name VARCHAR( 250 ) NOT NULL ,
armor_type VARCHAR( 250 ) NOT NULL ,
armor_level SMALLINT UNSIGNED NOT NULL ,
covers TINYINT UNSIGNED NOT NULL ,
craft TINYINT UNSIGNED NOT NULL ,
tinks TINYINT UNSIGNED DEFAULT '0',
value SMALLINT UNSIGNED NOT NULL ,
wield_meleed SMALLINT UNSIGNED,
wield_missiled SMALLINT UNSIGNED,
wield_magicd SMALLINT UNSIGNED,
act_meleed SMALLINT UNSIGNED,
act_missiled SMALLINT UNSIGNED,
act_magicd SMALLINT UNSIGNED,
act_rank SMALLINT UNSIGNED DEFAULT '0',
act_race SMALLINT UNSIGNED DEFAULT '0',
act_arcane SMALLINT UNSIGNED,
imbue TINYINT UNSIGNED,
date_posted DATETIME NOT NULL ,
date_ends DATETIME NOT NULL ,
armor_status CHAR DEFAULT '0',
seller INT NOT NULL ,
high_bidder INT NOT NULL ,
low_bidder INT NOT NULL ,
bids_total INT UNSIGNED DEFAULT '0',
low_bid SMALLINT UNSIGNED DEFAULT '0',
high_bid SMALLINT UNSIGNED DEFAULT '0',
spells VARCHAR( 250 ) ,
major1 VARCHAR( 250 ) DEFAULT 'empty',
major2 VARCHAR( 250 ) DEFAULT 'empty',
major3 VARCHAR( 250 ) DEFAULT 'empty',
major4 VARCHAR( 250 ) DEFAULT 'empty',
minor1 VARCHAR( 250 ) DEFAULT 'empty',
minor2 VARCHAR( 250 ) DEFAULT 'empty',
minor3 VARCHAR( 250 ) DEFAULT 'empty',
minor4 VARCHAR( 250 ) DEFAULT 'empty'
)

Bedankt, ik zal je eens een pint trakteren in café naar keuze in Leuven :D

Posted: Thu Jul 28, 2005 4:47 pm
by sulen
It has got to do with the position of attributes of the column ........... the first line should be like this

INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY

Posted: Thu Jul 28, 2005 5:44 pm
by timvw
Well, he said in dutch he understood what i meant and he was able to solve his problem ;)

And that he was going to buy me a beer :)

Image