Assuming you have some user input as a string:
user_input = 'a,b,c'
and a posts
table with a value1
column. You can get posts
with values a
, b
or c
with the following query:
values = user_input.split(',')
#=> ["a", "b", "c"]
DB = Sequel.sqlite
#=> #<Sequel::SQLite::Database: {:adapter=>:sqlite}>
dataset = DB[:posts]
#=> #<Sequel::SQLite::Dataset: "SELECT * FROM `posts`">
dataset.where(:value1 => values).sql
#=> #<Sequel::SQLite::Dataset: "SELECT * FROM `posts` WHERE (`value1` IN ('a', 'b', 'c'))">