如何在MySql中使用“value”作为列名?

时间:2012-04-19 04:15:19

标签: mysql

如何在MySql的select语句中使用value?它是保留关键字。

代码:

SELECT unit.cleunit
 FROM    (   (   metas metas
           INNER JOIN
              metas_unit metas_unit
           ON (metas.clemetaunit = metas_unit.clemetaunit))
       INNER JOIN
          metas_values metas_values
       ON (metas_values.clemetaunit = metas.clemetaunit)
      AND (metas_unit.clemetaunit_values =
              metas_values.clemetaunit_values))
   INNER JOIN
      unit unit
   ON (unit.cleunit = metas_unit.cleunit)

WHERE(unit.etatunit<> 0)    AND(unit.isdeleteunit = 0)    AND((metas_unit。value LIKE'%% NOM %%')     或(metas_values.metavalues_name LIKE'%% NOM %%'))

1 个答案:

答案 0 :(得分:4)

尝试以下方法:

SELECT * FROM MyTable WHERE `Value` = 1

有关详细信息,请参阅reserved字词和identifiers

更新:sql查询:

SELECT unit.cleunit
FROM metas
INNER JOIN metas_unit 
    ON metas.clemetaunit = metas_unit.clemetaunit
INNER JOIN metas_values 
    ON metas_values.clemetaunit = metas.clemetaunit
    AND metas_unit.clemetaunit_values = metas_values.clemetaunit_values
INNER JOIN unit
    ON unit.cleunit = metas_unit.cleunit
WHERE unit.etatunit <> 0 
    AND unit.isdeleteunit = 0 
    AND (metas_unit.`value` LIKE '%%NOM%%' 
         OR metas_values.metavalues_name LIKE '%%NOM%%')