Rails problem find by sql

Posted by Totty on Stack Overflow See other posts from Stack Overflow or by Totty
Published on 2010-04-04T23:37:05Z Indexed on 2010/04/04 23:43 UTC
Read the original article Hit count: 285

Filed under:
|

I have this query and I have an error:

images = Image.find_by_sql('PREPARE stmt FROM \'
  SELECT *
  FROM images AS i
  WHERE i.on_id = 1 AND i.on_type = "profile"
  ORDER BY i.updated_at
  LIMIT ?, 6\
'; SET @lower_limit := ((5 DIV 6) * 6);  EXECUTE stmt USING @lower_limit;')

Mysql::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 'SET @lower_limit := ((5 DIV 6) * 6); EXECUTE stmt USING @lower_limit' at line 1: PREPARE stmt FROM ' SELECT * FROM images AS i WHERE i.on_id = 1 AND i.on_type = "profile" ORDER BY i.updated_at LIMIT ?, 6'; SET @lower_limit := ((5 DIV 6) * 6); EXECUTE stmt USING @lower_limit;

© Stack Overflow or respective owner

Related posts about rails

Related posts about mysql