多列 in 的语句如何写

acaicb 2008-03-10 02:57:26
请问在sql server里面多列in操作的语句如何写?如:

select * from TB1
where (COL1,COL2) IN (SELECT COL1,COL2 FROM TB2);
...全文
125 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
-狙击手- 2008-03-10
  • 打赏
  • 举报
回复
为什么不能发
-狙击手- 2008-03-10
  • 打赏
  • 举报
回复
为什么不能发
-狙击手- 2008-03-10
  • 打赏
  • 举报
回复
为什么不能发
dawugui 2008-03-10
  • 打赏
  • 举报
回复
--推荐这个.
select tb1.* from tb1,tb2
where tb1.col1 = tb2.col1 and tb1.col2 = tb2.col2


--也可尝试这个
select * from tb1
where exists(select 1 from tb2 where tb2.col1 = tb1.col1 and tb2.col2 = tb1.col2)
yinqi025 2008-03-10
  • 打赏
  • 举报
回复
支持...双重in对大数据表绝对是不可取的
[Quote=引用 1 楼 liangCK 的回复:]
SQL codeselect * from tb1
inner join tb2
on tb1.col1=tb2.col1 and tb1.col2=tb2.col2
[/Quote]
moyifeng 2008-03-10
  • 打赏
  • 举报
回复
tong yi er lou de
areswang 2008-03-10
  • 打赏
  • 举报
回复
select * from TB1
where COL1 IN (SELECT COL1 FROM TB2)
AND COL2 IN (SELECT COL2 FROM TB2)
liangCK 2008-03-10
  • 打赏
  • 举报
回复
select * from tb1
inner join tb2
on tb1.col1=tb2.col1 and tb1.col2=tb2.col2

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧