#1064 - You have an error in your SQL syntax

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

#1064 - You have an error in your SQL syntax

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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)
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

Post by nutkenz »

Ah, een Leuvenaar :)

Ik zal het even proberen met die volgorde...
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

Post 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
User avatar
sulen
Forum Commoner
Posts: 79
Joined: Wed Jul 09, 2003 4:55 pm
Location: los angeles
Contact:

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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
Post Reply