使用Select语句时如何在mysql中转义value关键字 [英] How to escape value keyword in mysql while using Select statement
问题描述
使用Select语句时,我遇到一个问题,在该语句中,列名为值",并且我想使用SELECT
和LIKE
运算符基于值"列检索值.
I am facing a problem while using Select statement where I have a column name as 'Value', and I want to retrieve the values based on the 'value' column with SELECT
and LIKE
operators.
代码:
SELECT compo.clecompo
FROM compo compo
ON (compo.clecompo = metadatas_compo.clecompo)
AND ((metadatas_compo.value LIKE '%%NOM%%')
OR (metadatas_values.metavalues_name LIKE '%%NOM%%'))
我突出显示了value关键字..这是我的查询示例,但没有得到任何结果.
注意:(metadatas_compo.value)
metadatas_compo
是表名.
I highlighted the value keyword.. It's a sample of my query where i am not getting any results.
Note: (metadatas_compo.value)
metadatas_compo
is table name.
推荐答案
您可以使用反引号`
SELECT compo.clecompo FROM compo compo ON (compo.clecompo = metadatas_compo.clecompo) AND ((metadatas_compo.`value` LIKE '%%NOM%%') OR (metadatas_values.metavalues_name LIKE '%%NOM%%'))
但是,建议不要在表/列名称中使用保留文字.有关保留字的列表:
However, it is advised to not use reserved literals in your table/column names. For a list of reserved words:
http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
这篇关于使用Select语句时如何在mysql中转义value关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!