On Monday, May 14, 2018 at 10:57:14 PM UTC-7, Fatih Genç wrote:
>
> Hi,
>
> I'm tring to build a query with more than 1 table as fallows
>
>     ds = 
> DB.select("r.year,r.prod,r.type,r.amnt,r.ccur,r.dcnt,r.dbcr,r.rcdt,r.stat 
> ,p.code as partner_code,p.desc as partner_desc,p.txid")
>     ds = ds.from("#{Rank.table_name.to_s} r","#{Partner.table_name.to_s} 
> p")
>     ds = ds.where(Sequel.lit('r.ptid = p.id'))
>
>     ds.first returns an error "no such table: ranks r"
>

> What should I do to fix this?
>

Probably use Sequel's API to represent the objects:

ds = DB.from(Sequel.as(Rank.table_name, :r), Sequel.as(Partner.table_name, 
:p)).
  select{[r[:year], r[:prod], r[:type], r[:amnt], r[:ccur], r[:dcnt], 
r[:dbcr], r[:cdrt], r[:stat], p[:code].as(:partner_code), 
p[:desc].as(:partner_desc), p[:txid]]}.
  where{{r[:ptid]=>p[:id]}} 

You could also just use Sequel.lit around each argument to select and from.

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 post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to