On Nov 9, 9:00 am, bsdev <[email protected]> wrote:
> This is the query I want to get:
> select "ID", "NAME", "CITY" from "USER" where lower("EMAIL") =
> 'mailaddress' or lower("NAME") like 'i%' or lower("CITY") like 'l%';

irb(main):001:0> require 'sequel'; DB = Sequel.sqlite
=> #<Sequel::SQLite::Database: "sqlite:/">

irb(main):002:0> selected = DB[:USER].select(:ID, :NAME, :CITY)
=> #<Sequel::SQLite::Dataset: "SELECT `ID`, `NAME`, `CITY` FROM
`USER`">

irb(main):003:0> selected.filter( :lower.sql_function(:EMAIL) =>
"mail" ).sql
=> "SELECT `ID`, `NAME`, `CITY` FROM `USER` WHERE (lower(`EMAIL`) =
'mail')"

irb(main):004:0> selected.filter( {:lower.sql_function(:EMAIL) =>
"mail"} | :lower.sql_function(:name).like("i%") | :lower.sql_function
(:CITY).like("l%") ).sql

=> "SELECT `ID`, `NAME`, `CITY` FROM `USER` WHERE (((lower(`EMAIL`) =
'mail') OR (lower(`name`) LIKE 'i%')) OR (lower(`CITY`) LIKE 'l%'))"


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to