Home  >  Article  >  Database  >  [小技巧]当字段名与MySQL保留字冲突的解决办法

[小技巧]当字段名与MySQL保留字冲突的解决办法

WBOY
WBOYOriginal
2016-06-07 16:39:351055browse

我们知道通常的SQL查询语句是这么写的: select col from table; 这当然没问题,但如果字段名是“from”呢? select from from table; 若真的这么写,必然出错,当字段名与MySQL保留字冲突时,可以用字符“`”将字段名括起来: select `from` from table; 搞

我们知道通常的SQL查询语句是这么写的:

select col from table;

这当然没问题,但如果字段名是“from”呢?

select from from table;

若真的这么写,必然出错,当字段名与MySQL保留字冲突时,可以用字符“`”将字段名括起来:

select `from` from table;

搞定。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn