如何编写mysql查询,以便我可以在列下选择等于resultA或resultB或resultC等的条目。
类似的东西:
SELECT * FROM myTable WHERE myColumn = resultA OR WHERE myColumn = resultB OR WHERE myColumn = resultC...
答案 0 :(得分:9)
SELECT *
FROM myTable
WHERE myColumn = 'resultA'
OR myColumn = 'resultB'
OR myColumn = 'resultC';
可替换地,
SELECT *
FROM myTable
WHERE myColumn IN ('resultA', 'resultB', 'resultC');
答案 1 :(得分:1)
多次使用WHERE
,只需在条件之间使用OR
SELECT *
FROM myTable
WHERE myColumn = 'resultA'
OR myColumn = 'resultB'
OR myColumn = 'resultC'
请注意,我将resultX
用单引号包围,假设它们是字符串,如果它们是整数,则可以省略它们
答案 2 :(得分:1)
这应该有用。
SELECT * FROM myTable WHERE myColumn = 'resultA' OR myColumn = 'resultB' OR myColumn = 'resultC'
答案 3 :(得分:1)
SELECT * FROM myTable WHERE myColumn in (resultA, resultB, resultC ....)