开发者

Select everything in a database that == something OR something else

I'm trying to select everything in a table where a column == "something" OR "somethingelse".

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

Table.where(:col => "something" OR "somethingelse")开发者_Go百科


Table.where(:col => ["something", "somethingelse"])

should generate

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


You can use:

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


You can use the statement like this:

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜