我有一个表,它有一个名为'from‘的列。我想从中检索数据,所以我尝试了下面的查询。
select title,from,grade from localcourses where title='new';但是由于列名'from‘,我得到了下面的异常。
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 'from,grade from localcourses where title='new'如何在不重命名列名的情况下避免这种情况?谢谢。
发布于 2011-09-06 03:26:12
在MySQL上,您可以使用`(后撇号--位于键盘上1键的左侧)。使用
`from`.发布于 2011-09-06 03:21:26
试试看
select `title`,`from`,`grade` from localcourses where `title`='new';发布于 2011-09-06 03:26:08
如果在标准(ANSI)模式下运行MySQL,请使用双引号对关键字进行“转义”:
select title,
"from",
grade
from localcourses
where title='new';如果你在非标准模式下运行MySQL (如果我没记错的话,这仍然是默认模式),你需要使用MySQL可怕的“反引号:
select title,
`from`,
grade
from localcourses
where title='new';https://stackoverflow.com/questions/7311990
复制相似问题