select t1.cid from a t1,a t2 where t1.tid in('1','2','3') and t2.tid in('4','5','6') and t1.cid=t2.cid
请问sql server分组后怎样能让只要其中一组数据满足where后面的多个条件之中一个就提取出来
比如:a表
- ID cid tid
- 1 1 1
- 2 1 5
- 3 2 1
- 4 2 2
要挑选tid在{1,2,3}和{4,5,6}之间的cid,那么cid=1输出,cid=2排除,这样sql怎么写?
- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答