请告诉我如何实现这个SQL查询:
select * from products where (category, category2, category3) in (2, 138, 136, 125)
错误:
#1241 - Operand should contain 3 column(s)
答案 0 :(得分:1)
只需在where子句中写下所有列,如下所示:
SELECT *
FROM products
WHERE
category IN (2, 138, 136, 125) OR
category2 IN (2, 138, 136, 125) OR
category3 IN (2, 138, 136, 125)
答案 1 :(得分:1)
select * from products
where category in (2, 138, 136, 125)
OR
category2 in (2, 138, 136, 125)
OR
category3 in (2, 138, 136, 125)
答案 2 :(得分:1)
select * from products where category in (2, 138, 136, 125)
AND category2 in (2, 138, 136, 125)
AND category3 in (2, 138, 136, 125)
或OR
,取决于要求。