Select everything in the database that == something or something else

I am trying to select everything in the table where the column == "something" OR "something".

Is there a way to do this without using raw SQL? Something like the following would be ideal.

Table.where(:col => "something" OR "somethingelse")
+3
source share
3 answers
Table.where(:col => ["something", "somethingelse"])

should generate

SELECT * FROM table WHERE col IN ('something', 'somethingelse')
+5
source

You can use:

MyModel.where("col1 = ? or col1 = ?", "something","somethingelse")
+2
source

You can use the operator as follows:

select * from table_name where column_name = value1 or column_name = value_2

You can also use:

select * from table_name where column_name in (value1,value2)
-1
source

All Articles