PDA

View Full Version : Whats wrong with this mySQL query?



coolblu
June 20th, 2003, 16:49
Hello all :)

Just wondering if you can tell me where I am going wrong with this - bit of a newbie with mySQL :)


CREATE TABLE `records` (

`id` INT( 7 ) NOT NULL AUTO_INCREMENT,
`cat` TEXT( 2 ) NOT NULL ,
`artistname` TEXT( 40 ) NOT NULL ,
`title` TEXT( 45 ) NOT NULL ,
`price` TEXT( 6 ) NOT NULL ,
`year` YEAR( 4 ) NOT NULL ,
`rcon` TEXT( 2 ) NOT NULL ,
`scon` TEXT( 2 ) NOT NULL ,
`desc` TEXT( 150 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `cat` , `artistname` , `title` , `price` , `year` , `rcon` , `scon` , `desc` )
)


Hope you can help :D

Thanks

dawizman
June 20th, 2003, 17:10
what is the error message?

keith
June 20th, 2003, 17:25
i don't think 'text' can be assigned a limiter, at least i never do. i think it's preset to 16kb or whatever it may be, but i'm probably wrong.

try using either 'char()' or 'varchar()', or just plain 'text':


CREATE TABLE records (
id INT(7) NOT NULL PRIMARY KEY AUTO_INCREMENT,
cat VARCHAR(2) NOT NULL,
artistname VARCHAR(40) NOT NULL,
title VARCHAR(45) NOT NULL,
price VARCHAR(6) NOT NULL,
year VARCHAR(4) NOT NULL,
rcon VARCHAR(2) NOT NULL,
scon VARCHAR(2) NOT NULL,
desc VARCHAR(150) NOT NULL
)

coolblu
June 20th, 2003, 17:31
I still get this with that code keith:


Error

SQL-query :

CREATE TABLE records(

id INT( 7 ) NOT NULL PRIMARY KEY AUTO_INCREMENT,
cat VARCHAR( 2 ) NOT NULL ,
artistname VARCHAR( 40 ) NOT NULL ,
title VARCHAR( 45 ) NOT NULL ,
price VARCHAR( 6 ) NOT NULL ,
year VARCHAR( 4 ) NOT NULL ,
rcon VARCHAR( 2 ) NOT NULL ,
scon VARCHAR( 2 ) NOT NULL ,
DESC VARCHAR( 150 ) NOT NULL
)

MySQL said:


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 'DESC VARCHAR( 150 ) NOT NULL )' at line 1
Back

I cant figure out where any of it is going wrong :confused2

dawizman
June 20th, 2003, 17:48
This works:



CREATE TABLE `records` (
`id ` INT( 7 ) NOT NULL AUTO_INCREMENT,
`cat ` VARCHAR( 2 ) NOT NULL ,
`artistname ` VARCHAR( 40 ) NOT NULL ,
`title ` VARCHAR( 45 ) NOT NULL ,
`price ` VARCHAR( 6 ) NOT NULL ,
`year ` VARCHAR( 4 ) NOT NULL ,
`rcon ` VARCHAR( 2 ) NOT NULL ,
`scon ` VARCHAR( 2 ) NOT NULL ,
`DESC ` VARCHAR( 150 ) NOT NULL ,
PRIMARY KEY ( `id ` )
);

coolblu
June 20th, 2003, 17:59
yay! Thanks very much DaWizman :D

dawizman
June 20th, 2003, 18:14
yeah, no problem.

keith
June 20th, 2003, 18:25
whoops, i'd forgotten the closing semicolon.