且构网

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

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

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

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.

附注.正如评论中指出的那样, 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.