我正在创建原始 MySQL 查询以使用 Laravel 的“DB”外观插入到我的数据库中。我已经得到了与另一个数据库表一起使用的相同类型的查询,但是它在这个特定的表上抛出了错误。
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 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 'group,originating_attorney,practice_area,responsible_attorney,statute_of_limitat' at line 1")
/home/vagrant/Code/proj/vendor/laravel/framework/src/Illuminate/Database/Connection.php:452
2 PDO::prepare("INSERT INTO firm_matters(id,etag,display_number,custom_number,description,status,location,client_reference,billable,maildrop_address,billing_method,open_date,close_date,pending_date,client,contingency_fee,custom_rate,group,originating_attorney,practice_area,responsible_attorney,statute_of_limitations,user,account_balances,custom_field_vals,custom_field_set_associations,created_at,updated_at) VALUES (...)
我检查了 MySQL 的保留关键字,我认为我没有违反任何规则。是否有人更精通 MySQL 检查我的查询是否正确。
最佳答案
I've checked the reserved keywords for MySQL
不,你没有
syntax to use near 'group,originating
^^^^^ here
GROUP
是保留字 https://dev.mysql.com/doc/refman/5.7/en/keywords.html
只是不要创建“原始 MySQL 查询”,下次你会没事的。你足够聪明,可以使用框架,但你使用“原始 MySQL 查询”。只是不要这样做。
关于php - MySQL 数据库查询抛出错误,说我有语法错误。好像找不到他们?我相信它在查询的列部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51776042/