更新时间:2023-10-23 14:45:46
嗯,你只需要 or 子句所关注的元素在括号.
Well, you just need the elements concerned by the or clause to be between parenthesis.
顺便说一下,它们不是需要的"(您可以使用 AND/OR 的优先顺序),但我会说这是提高可读性的***方式.
They are not "needed", by the way (you could use precedence order of AND / OR), but I would say this is the best way for readability.
如果 status_id 数据类型为 int,则不需要 ' '
1 和 2 左右.
And if status_id data type is int, you don't need the ' '
around 1, and 2.
SELECT *
FROM tablename
WHERE name='Ankit'
AND date='2015-04-23'
AND (status_id=1 OR status_id=2)
顺便说一句,在这种情况下,您可以使用 IN 子句
By the way, in this case, you may use an IN clause
AND status_id in (1, 2)