1比如,我要价格在20-30 50-60 70-80 价格区间的商品,关系为or
2同时标题要包含裙子,上衣,外套关系为or,
3还要排除标题包含童装,书籍,关系为and,
3个结果合并以id排序,然后取出数据.
这样的语句应该怎么写呀?
解决方案
select * from tb_name where
( (price between 20 and 30) or (price between 50 and 60) or (price between 70 and 80) ) and ( (title="裙子" or title="上衣" or title="外套") and (title<>'童装' or title<>'书籍') )
order by id asc;