且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误— PHP — PDO

更新时间:2022-01-18 21:23:48

from是SQL中的关键字.如果不引用,则不能将其用作列名.在MySQL中,列名之类的内容用反引号引起来,即`from`.

from is a keyword in SQL. You may not used it as a column name without quoting it. In MySQL, things like column names are quoted using backticks, i.e. `from`.

我个人不会打扰;我只是重命名该列.

Personally, I wouldn't bother; I'd just rename the column.

PS.如注释中所指出的,to是另一个SQL关键字,因此也需要将其引起来.方便地,drupal.org上的人员维护一个列表SQL中的保留字.

PS. as pointed out in the comments, to is another SQL keyword so it needs to be quoted, too. Conveniently, the folks at drupal.org maintain a list of reserved words in SQL.