I did join on three tables.
arel = OfferOrder.includes(:a, :b, :c) arel = arel.select('(CASE WHEN
ISNULL(c.field2) THEN c.field1 ELSE c.field2 END) AS fraud')
but when I run my code it gives error that
(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 'AS fraud)
on 2013-03-14 11:14
on 2013-03-14 11:18
Also I did try it this way,
arel = OfferOrder.includes(:a, :b).joins(:c).select('(CASE WHEN
ISNULL(c.fields2) THEN c.fields1 ELSE c.field2 END) ')
Got error,
ActiveModel::MissingAttributeError (missing attribute: a_id):
I did join on three tables.
on 2013-03-15 12:12
On Thu, Mar 14, 2013 at 5:16 AM, Sumit Srivastava <sumit.theinvincible@gmail.com> wrote: > >> near 'AS fraud) > What was the SQL it generated?
on 2013-03-15 12:16
On 15 March 2013 16:41, tamouse mailing lists <tamouse.lists@gmail.com>wrote: > > > >> (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 'AS fraud) > > > > What was the SQL it generated? > Resolved this. Had to defined the join conditions and it worked. Though am stuck on another. The select query is not working when another query is made using <<SQL tags in the code. Can't avoid using those. Regards Sumit Srivastava The power of imagination makes us infinite...
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.