0
USE waterloo;

DROP TABLE IF EXISTS waterloo;
CREATE TABLE waterloo
(
id              int unsigned NOT NULL auto_increment,   # Unique ID for the record
building        varchar(255) NOT NULL,                  # Name of building
floor           int unsigned NOT NULL,                  # Floor of building
gender          varchar(255) NOT NULL,                  # Gender of bathroom
location        int unsigned NOT NULL,                  # Convenience of location of     bathroom
cleanliness     int unsigned NOT NULL,                  # Cleanliness of bathroom
stalls          int unsigned NOT NULL,                  # Number of stalls
noise           int unsigned NOT NULL,                  # Ambient noise
lines           int unsigned NOT NULL,                  # Length of lines at peak hours
graffiti        int unsigned NOT NULL,                  # Amount of graffiti on the walls
PRIMARY KEY     (id)
);

I get the following error:

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 'lines int unsigned NOT NULL, graffiti int unsigned NOT NULL )' at line 11

1
  • Maybe you forgot to add a boolean field "flushed"? Commented Feb 16, 2013 at 2:34

2 Answers 2

2

LINES is a reserved word in MySQL. You can still use it as a column name, though. Just wrap it in backtics

`lines`
Sign up to request clarification or add additional context in comments.

Comments

0

Lines is a reserved word in MySQL -- add ticks around it and it should work.

http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

CREATE TABLE waterloo
(
id              int unsigned NOT NULL auto_increment,   # Unique ID for the record
building        varchar(255) NOT NULL,                  # Name of building
floor           int unsigned NOT NULL,                  # Floor of building
gender          varchar(255) NOT NULL,                  # Gender of bathroom
location        int unsigned NOT NULL,                  # Convenience of location of     bathroom
cleanliness     int unsigned NOT NULL,                  # Cleanliness of bathroom
stalls          int unsigned NOT NULL,                  # Number of stalls
noise           int unsigned NOT NULL,                  # Ambient noise
`lines`           int unsigned NOT NULL,                  # Length of lines at peak hours
graffiti        int unsigned NOT NULL,                  # Amount of graffiti on the walls
PRIMARY KEY     (id)
);

Hope that helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.