菲凡双宝 2019-08-12 14:50 采纳率: 0%
浏览 262

求助:某个字段内两个条件都满足的情况怎么写,新手上路,求扶

oderID color

1 红色

1 黄色

2 红色

2 绿色

3 黄色

3 绿色

4 红色

4 黄色

查询color既有红色又有黄色的oderID
结果为 1
4 这个怎么写 各位大神

  • 写回答

5条回答 默认 最新

  • Zacharl 2019-08-12 15:51
    关注

    select orderid,color from table t1 where t1.color='红色' and exists (select 1 from table t2 where t2.color='黄色' and t1.orderid=t2.orderid);

    评论

报告相同问题?