我想从这个查询结果给出价格范围给我一个正确的查询
SELECT id,tableid,category,price,actualprice,image,title,website,description
FROM tt_1
where
title like 'Home Appliances%' or
image like 'Home Appliances%' or
category like 'Home Appliances%' or
site_master_url like 'Home Appliances%' or
website like 'Home Appliances%'
答案 0 :(得分:2)
问题不清楚。
我相信这就是你想要的。要在mysql中指定一个范围,请使用BETWEEN
SELECT * FROM table WHERE price BETWEEN lower AND upper;
答案 1 :(得分:1)
我将保持你在那里的逻辑(我认为你应该使用AND而不是OR,如果你正在过滤数据,但你会更清楚你需要什么)这将获得100-1000之间的价格:
SELECT id,tableid,category,price,actualprice,image,title,website,description FROM tt_1 where title like 'Home Appliances%' or image like 'Home Appliances%' or category like 'Home Appliances%' or site_master_url like 'Home Appliances%' or website like 'Home Appliances%' or (price > 100 AND price < 1000)
答案 2 :(得分:1)
其他答案中没有人理解operator precedence吗?
SELECT id,tableid,category,price,actualprice,image,title,website,description
FROM tt_1
where
(
title like 'Home Appliances%' or
image like 'Home Appliances%' or
category like 'Home Appliances%' or
site_master_url like 'Home Appliances%' or
website like 'Home Appliances%'
)
AND
price BETWEEN @LowerBound AND @UpperBound;
最后一行也可能是这样(为清晰起见,括号):
AND
(price >= @LowerBound AND price <= @UpperBound)
答案 3 :(得分:0)
问题未被清除。我想你想用这个查询来结算价格区间。请尝试使用它,让我知道。如果您的价格是整数,则从数字中删除报价。
SELECT id,tableid,category,price,actualprice,image,title,website,description
FROM tt_1
where
title like 'Home Appliances%' or
image like 'Home Appliances%' or
category like 'Home Appliances%' or
site_master_url like 'Home Appliances%' or
website like 'Home Appliances%' AND
price between 'STARTING_RANGE' AND 'ENDING_RANGE'