如何在单个变量查询mysql的地方做X或Y?

时间:2013-06-07 16:06:37

标签: mysql

我想要做的伪查询如下:

从mytable中选择* where(myintvalue = 0 OR 1)AND anothervalue =“SomeValue”

上述语法的正确语法是什么?

3 个答案:

答案 0 :(得分:1)

使用IN子句

Select * from mytable where myvalue IN( 0,1) AND anothervalue = "SomeValue"

答案 1 :(得分:1)

WHERE (myintvalue = 0 OR myintvalue = 1)
/* or */
WHERE myintvalue IN (0, 1)

答案 2 :(得分:1)

SELECT * FROM mytable where (myintvalue = 0 OR myintvalue = 1) AND anothervalue= 'SomeValue';

SELECT * FROM mytable where myintvalue in (0,1) AND anothervalue= 'SomeValue';

应该做的伎俩