-3

I have a table named condition, and whenever I try to query the table or insert data into it I am getting an error.

CREATE TABLE IF NOT EXISTS `PrisonDB`.`Condition` (
`condition_id` INT NOT NULL,
`condition_description` VARCHAR(45) NULL,
PRIMARY KEY (`condition_id`))
ENGINE = InnoDB;

And if I try to query it I get:

mysql> select * from condition;

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 'condition'
at line 1

Everything looks right to me, the only thing I can think of is condition is a special keyword or something in mySQL.

Talen Kylon
  • 1,908
  • 7
  • 32
  • 60
  • 3
    You can easily look up the full list... https://dev.mysql.com/doc/refman/5.5/en/reserved-words.html – Sam Dufel Mar 22 '14 at 00:47
  • 2
    This question appears to be off-topic because [Google exists](https://www.google.com.au/search?q=mysql+reserved+words) – ta.speot.is Mar 22 '14 at 00:56

3 Answers3

3

Yes, condition is a reserved word as of MySQL 5.0. Your original Create Table works because you can use ` to quote reserved words for use in table/field names.

Works:

SELECT * FROM `condition`;
DROP TABLE `condition`;
# etc.

Doesn't:

SELECT * FROM condition
Brian North
  • 1,398
  • 1
  • 14
  • 19
0

Yes it is check this link please

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

you should either use ` or change name of the table

Siavosh
  • 2,314
  • 4
  • 26
  • 50
0

CONDITION is a reserved word in MySQL.

mike
  • 55
  • 11