有没有一种方法可以缩短下面的SQL
语句:
SELECT id, name FROM table_name
WHERE
status = 0 && price BETWEEN 20 AND 1000
&& city_id IN (7,8)
OR
status = 0 && price BETWEEN 20 AND 1000
&& country_id IN (4,14)
答案 0 :(得分:2)
请尝试:
SELECT id, name FROM table_name
WHERE
status = 0 && price BETWEEN 20 AND 1000
&& (city_id IN (7,8) OR country_id IN (4,14))
答案 1 :(得分:1)
您可以在下面尝试-
SELECT id, name FROM table_name
WHERE status = 0 and price BETWEEN 20 AND 1000 and
(city_id IN (7,8,) or country_id IN (4,14))
答案 2 :(得分:1)
这是您的查询。
select id, name from table_name
where
status = 0 and price between 20 and 1000
and (
city_id IN (7,8)
or
country_id IN (4,14)
)