On Nov 22, 6:32 pm, Joe Van Dyk <[email protected]> wrote:
> I've got a query like:
>
> select table1.*
> from table1
> inner join table2 on table2.table1_id = and (table2.name ilike '%blah
> %' or table2.name ilike '%foo%')
>
> How can I write this in Sequel syntax?
>
> I know I can use Dataset#grep to add conditions to the "where" clause,
> but not sure how to add conditions to the join on clause.
>
> Thanks,
> Joe
DB[:table1].join(:table2, {:table1__col1 => :table2__col2} &
((:table2__col3).ilike('%blah%') | (:table2__col3).ilike('%foo%')))
Or use a join block
http://sequel.rubyforge.org/rdoc/files/doc/querying_rdoc.html
--
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.