我试图在我的 Rails 控制台中运行以下行:
ActiveRecord::Base.connection.execute "DELETE FROM recommendations WHERE place_id=4000000001267 AND recommender_id=2728498;UPDATE IGNORE recommendations SET place_id=4000000001267 WHERE place_id=4000000564630 AND recommender_id=2728498;"
它只是删除旧记录并重写另一条记录以进行合并。
Rails 控制台返回以下内容:
DELETE FROM recommendations WHERE place_id=4000000001267 AND recommender_id=2728498;UPDATE IGNORE recommendations SET place_id=4000000001267 WHERE place_id=4000000564630 AND recommender_id=2728498;
ActiveRecord::StatementInvalid: Mysql2::Error: 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 'UPDATE IGNORE recommendations SET place_id=4000000001267 WHERE place_id=40000005' at line 1: DELETE FROM recommendations WHERE place_id=4000000001267 AND recommender_id=2728498;UPDATE IGNORE recommendations SET place_id=4000000001267 WHERE place_id=4000000564630 AND recommender_id=2728498;
from /Users/huynguyen/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in
查询'`
但是,当我在 Sequel Pro 中运行这个精确查询时,查询运行得非常好。知道发生了什么吗?