选择带有关键字名称的列 [英] Select a column with a keyword name
本文介绍了选择带有关键字名称的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为"test"的表
I have a table named 'test'
它包含一个名为"AND"的列
It contains a column named 'AND'
为此,我使用以下查询
insert into test values ('a','abc');
insert into test values ('b','def');
现在我想从测试"表中选择与"列
Now I want to select my 'AND' column from the 'test' table
查询select AND from test;
将不起作用,因为AND是关键字
The query select AND from test;
wont work because AND is keyword
我尝试了
select "AND" from test;
select 'AND' from test;
两个查询都返回错误的结果,如下所示
Both queries return the wrong results as show below
如何选择与"列?
推荐答案
使用backtick
转义关键字.就像您创建表格的方式一样.使用双引号或单引号会将其解析为string
,这就是为什么您要获得两个and
use backtick
to escape keyword instead. just like how you created your table. using double quote or single quote will parse it into string
that is why you're getting two records of and
select `AND` from test;
这篇关于选择带有关键字名称的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文