0
觀點:紅寶石軌道MySQL服務器版本的正確語法使用附近'?的find_by_sql
<% Favorite.find_by_sql("SELECT p.* FROM favorites as f LEFT JOIN posts as p ON p.user_id = f.user_id WHERE f.user_id = ? limit 15", @user.id).reverse.each do |post| %>
我收到以下錯誤:
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 '? limit 15' at line 1: SELECT p.* FROM favorites as f LEFT JOIN posts as p ON p.user_id = f.user_id WHERE f.user_id = ? limit 15
什麼我基本上想是讓我有收藏
謝謝我打算這樣做,只是想確保查詢工作的第一手 – fxuser