公司的这个查询需要优化,不知道这段逻辑应该怎么写...
简化模型如下:
t表 有 a b c 三个字段
原sql为:
select * from t
where a = "配送"
and b = 2
union
select * from t
where a = "收款"
and c =2
能用一个select 语句搞定吗?
应用中表达的意思就是查询出来配送或者收款到达2这个阶段的订单
望大神不腻赐教 :oops:
公司的这个查询需要优化,不知道这段逻辑应该怎么写...
简化模型如下:
t表 有 a b c 三个字段
原sql为:
select * from t
where a = "配送"
and b = 2
union
select * from t
where a = "收款"
and c =2
能用一个select 语句搞定吗?
应用中表达的意思就是查询出来配送或者收款到达2这个阶段的订单
望大神不腻赐教 :oops:
300万只能是小表,随便哪个数据库都可以用or来完成,楼主多虑了。