简体   繁体   中英

SELECT Query Not Working when selecting particular column 'condition'

TBL_condition

  ID CONDITION
  1     AAA
  2     BBB
  3     CCC

When I hit this query:

    SELECT CONDITION FROM TBL_condition

It says:

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

try using backticks (`) around CONDITION :

SELECT `CONDITION` FROM `TBL_condition`;

Condition is a term used by mysql. read more on this site: http://forums.mysql.com/read.php?101,40643,40643

CONDITION is reserved word in mysql http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

try like this

SELECT `CONDITION` FROM TBL_condition

This might have to do with CONDITION being a function in SQL. You have to put it like this `CONDITION` to prevent such things.

CONDITION is a reserved word for MySQL. it is used as for declare a condition like:

DECLARE condition_name CONDITION FOR condition_value

so you need to use backticks(`) around in any reserved word in your any query.like:

`CONDITION` 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM