On Aug 19, 12:42 pm, Jim Morris <[EMAIL PROTECTED]> wrote: > How would I generate the equivalent to this SQL? > > SELECT * FROM transactions t, users u, resources r WHERE u.id = > t.user_id AND r.id = t.resource_id; > > I tried this but the second join_table refers to the first joined > table not the original. > > DB[:transactions].join_table(:inner, :users, :id > => :user_id).join_table(:inner, :resources, :id => :resource_id).sql
If you want that exact SQL, you shouldn't use an explicit join, you should use multiple from tables. DB.from(:transactions___t, :users___u, :resources___r).filter(:u__id=>:t__user_id, :r__id=>:t__resource_id) Personally, I try to avoid that and instead use explicit joins (and avoid the unnecessary table aliasing): DB[:transactions].join(:users, :id=>:user_id).join(:resources, :id=>:transactions__resource_id) Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
