Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

greater than, less than inequalities used with SQL formula possible? #579

troynt opened this Issue Nov 1, 2012 · 1 comment


None yet
2 participants

troynt commented Nov 1, 2012


I'm attempting to do something like...

SELECT * FROM foo WHERE 10*field + 1 >= 21;

How do I get Sequel to recognize this?

Does Sequel have the ability to use tokens? e.g. ["10*field + 1 >= ?", 21]

I've spent a lot of time trying to figure this out, it should probably be added to the documentation, if this is possible.




jeremyevans commented Nov 1, 2012

The Sequel way to do that would be to use a virtual row block:

DB[:foo].where{field*10 + 1 >= 21}

You can also use a string with placeholders:

DB[:foo].where("10*field + 1 >= ?", 21)

This is already covered in multiple places in the documentation, I'm sorry if you missed it (I know there is a lot of documentation to review):

Dataset Filtering: http://sequel.rubyforge.org/rdoc/files/doc/dataset_filtering_rdoc.html
Virtual Row Blocks: http://sequel.rubyforge.org/rdoc/files/doc/virtual_rows_rdoc.html
Sequel for SQL Users: http://sequel.rubyforge.org/rdoc/files/doc/sql_rdoc.html

In the future, please request help and/or ask usage questions on the sequel-talk Google Group. Only bugs reports should be posted directly to GitHub Issues. Unless you are sure you've found a bug in the library, please ask on sequel-talk first before posting on GitHub Issues.

@jeremyevans jeremyevans closed this Nov 1, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment