有没有办法选择在同一个字段中出现多个条件中的任何一个的数据?
示例:我通常会写一个语句,例如:
select * from TABLE where field = 1 or field = 2 or field = 3
有没有办法代替说:
select * from TABLE where field = 1 || 2 || 3
任何帮助表示赞赏.
当然,最简单的方法是:
select foo from bar where baz in (1,2,3)
select * from TABLE where field IN (1,2,3)
您还可以方便地将其与仅返回一个字段的子查询组合:
select * from TABLE where field IN (SELECT boom FROM anotherTable)
要么:
SELECT foo FROM bar WHERE baz BETWEEN 1 AND 3