On Monday, June 8, 2015 at 2:57:42 PM UTC-4, Jeremy Evans wrote: > > On Monday, June 8, 2015 at 11:19:40 AM UTC-7, danj wrote: >> >> I have a working query against postgresql that I was hoping to convert to >> Sequel. I've been using sql for more years than I can count, but this is my >> first use of a nested join. There may be another way to do it. But here is >> what I have, which returns the expected data: >> >> >> SELECT a.*, b.info >> >> FROM >> >> api as a >> >> left outer join (m_tuples as m inner join api as b on >> b.event_id=m.event_id and b.r_id=15) on a.m_id=m.m_id >> >> where >> >> a.r_id = 27 >> > > Sequel doesn't currently support this style of join. You have to use a > subquery: > > DB[:api___a]. > select_all(:a). > select_append(:b__info). > left_outer_join(DB[:m_tuples___m].join(:api___b, :event_id=>:event_id, > :r_id=>15).as(:m), :m_id=>:m_id). > where(:a__r_id=>27) > > I believe PostgreSQL will optimize them the same, though it may be worth > confirming that. > > While this style of join is supported by SQL92, I've rarely seen it used, > and it doesn't really fit with Sequel's focus on datasets, which may be the > reasons Sequel has never supported it. > > Thanks, > Jeremy >
Thanks Jeremy! Your reply is right on. The query planner EXPLAIN output is exactly the same. Your point about why it's not supported makes perfect sense, which is also why I've probably never used this syntax before. Sequel is really great, my compliments to the Chef. Best wishes, Dan -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
