Awesome. Much appreciated! That actually answered 3 questions I had. On Fri, Jan 10, 2020 at 3:10 PM Jeremy Evans <jeremyeva...@gmail.com> wrote:
> On Friday, January 10, 2020 at 12:35:55 PM UTC-8, Todd wrote: >> >> I'm a Sequel noobie and I either don't understand the DSL correctly >> and/or simply missing something that's obvious. I want to do this... >> >> SELECT nutrient, a.amt + b.amt AS total FROM anatomy a JOIN anatomy b >> USING (nutrient) WHERE a.food = '23575' AND b.food = '31008'; >> > > Sequel code: > > DB.from{anatomy.as(:a)}. > join(:anatomy, [:nutrient], :table_alias=>:b). > select{[:nutrient, (a[:amt] + b[:amt]).as(:total)]}. > where{{a[:food]=>'23575', b[:food]=>'31008'}} > > SQL generated: > > SELECT nutrient, (a.amt + b.amt) AS total FROM anatomy AS a INNER JOIN > anatomy AS b USING (nutrient) WHERE ((a.food = '23575') AND (b.food = > '31008')) > > Thanks, > Jeremy > > -- > 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 sequel-talk+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sequel-talk/d426b241-dc61-47ba-be28-1234ec1d4624%40googlegroups.com > <https://groups.google.com/d/msgid/sequel-talk/d426b241-dc61-47ba-be28-1234ec1d4624%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 sequel-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/CA%2BZVAB2WCuzswx4Oxbb1a3LaEZm-re59ojynCAaYHNaH%3DK88_Q%40mail.gmail.com.