Rails more statements with ; doesnt work... :s
Posted
by user305270
on Stack Overflow
See other posts from Stack Overflow
or by user305270
Published on 2010-04-03T15:05:58Z
Indexed on
2010/04/03
15:13 UTC
Read the original article
Hit count: 268
I have this code, but i cant make it work:
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;')
I got this error:
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;
but if i use a sql app, like this, it works:
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