zach zach - 6 months ago 37
Linux Question

mysql INT(11) error

I am trying to create a table and I thought everything looked good but this error keeps coming up.

ERROR 1064 (42000): 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 '(11) NOT NULL,
menu_name VARCHAR(30) NOT NULL,
position INT(3) NOT NULL,
visi' at line 3

Here is the command I entered in the terminal:

mysql> CREATE TABLE pages (
-> ID INT(11) NOT NULL AUTO_INCREMENT,
-> subject_id(11) NOT NULL,
-> menu_name VARCHAR(30) NOT NULL,
-> position INT(3) NOT NULL,
-> visible TINYINT(1) NOT NULL,
-> context TEXT,
-> PRIMARY KEY (id),
-> INDEX (subject_id)
-> );


What am I doing wrong?

Thanks!

Answer

Problem near < subject_id >

 CREATE TABLE pages (
    -> ID INT(11) NOT NULL AUTO_INCREMENT,
    ->  subject_id INT(11) NOT NULL,
    ->  menu_name VARCHAR(30) NOT NULL,
    ->  position INT(3) NOT NULL,
    ->  visible TINYINT(1) NOT NULL,
    ->  context TEXT,
    ->  PRIMARY KEY (id),
    ->  INDEX (subject_id)
    -> );