如何筛选出想要的结果?

torrent2008 2005-03-18 01:46:04
如何筛选出想要的结果?
不同数据库的两个表A和表B
表A字段为A1,A2,A3,A4
表B字段为B1,B2,B3,B4
要求:
筛选出A1=B1 and A2=B2 and A3=B3的记录

谢谢!

...全文
105 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
talantlee 2005-03-25
  • 打赏
  • 举报
回复
delete ll from A as ll,B as rr where ll.a1=rr.b1 and ll.a2=rr.b2 and ll.a3=rr.b3
delete ll from B as rr,A as ll where ll.a1=rr.b1 and ll.a2=rr.b2 and ll.a3=rr.b3
我也調試過
Well 2005-03-25
  • 打赏
  • 举报
回复
select a.a1 into #ab from a,b where a.a1=b.b1 and a.a2=b.b2 and a.a3=b.b3
delete a where a1 in (select a1 from #ab)
delete b where b1 in (select a1 from #ab)
這樣一定行的﹗﹗我調試過﹗﹗
torrent2008 2005-03-25
  • 打赏
  • 举报
回复
ding!
torrent2008 2005-03-18
  • 打赏
  • 举报
回复
ding!
3k!
netDust_cv 2005-03-18
  • 打赏
  • 举报
回复
可能要做级联删除才可。
netDust_cv 2005-03-18
  • 打赏
  • 举报
回复
好像一条语句中删除两个表中的记录。
torrent2008 2005-03-18
  • 打赏
  • 举报
回复
重申一下,欲实现的目的
表A中
A1 A2 A3
10 002 50
11 003 100
12 004 150
13 005 200
表B中
B1 B2 B3
10 002 40
11 003 100
20 004 150
13 500 200
欲实现的结果是
表B中
11 003 100
--------------------
上述三个条件同时满足的记录作删除处理,
只保留不同时满足三个条件的记录

谢谢!
xluzhong 2005-03-18
  • 打赏
  • 举报
回复
select a.*,b.*
from 库名..a a join 库名..b b on a.A1=b.B1 and a.A2=b.B2 and a.A3=b.B3
xluzhong 2005-03-18
  • 打赏
  • 举报
回复
select a.*,b.*
from a join b on a.A1=b.B1 and a.A2=b.B2 and a.A3=b.B3
torrent2008 2005-03-18
  • 打赏
  • 举报
回复
两个数据库?
jinjazz 2005-03-18
  • 打赏
  • 举报
回复
select a.*,b.* from a,b where A1=B1 and A2=B2 and A3=B3

34,590

社区成员

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

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