SQL语句求助 有两张表A 表B表A的记录条数多 表B的记录条数少如果要选出表A中不包含表B的记录 这个SQL怎么写啊select * from 表A where not in 表B吗?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 --测试select * from aleft join b on a.id = b.idwhere b.id is null 二张表有关联的话,就可以这样select * from A where ID not in (select ID from B) select * from 表A where id not in (select id from 表B) select * from a where not exists (select * from b where a.id=b.id) 先 select * from A inner join B然后delete all再看A表里的数据就行了,呵呵,此方法仅供娱乐! drop table tab1drop table tab2gocreate table tab1(a int,b datetime)insert into tab1 select 12 , '2008-8-12'insert into tab1 select 12 , '2008-8-12' insert into tab1 select 12 , '2008-8-14' insert into tab1 select 15 , '2008-01-12' insert into tab1 select 15 , '2008-2-14' insert into tab1 select 17 , '2008-2-5' create table tab2(a int,b datetime)insert into tab2 select 12 , '2008-8-12'insert into tab2 select 12 , '2008-8-12' select *from tab1where not exists(select 1 from tab2 where tab1.a=tab2.a and tab1.b=tab2.b) select * from 表A where id not in (select id from 表B) select * from A where id not in (select id from B) select * from A where not exists (select id from B) select * from A where id not in(select id from b) C++动态创建Oracle触发器,创建后缺失了一段,求解。拜谢 win7 配置b/s 模式程序 sqlserver2000的视频教程下载 如何删除本地发布 求sql导入语句 WITH 语句能否再次使用INNER JOIN语句 有点挑战性的SQL查询语言的写法 怎样在表中造假字段 非常非常初级的问题 能不能通过脚本代码生成一个作业? ms sql 项目管理系统 求一个SQL语句的问题
--测试
select * from a
left join b on a.id = b.id
where b.id is null
select * from A where ID not in (select ID from B)
select * from 表A where id not in (select id from 表B)
select * from a where not exists (select * from b where a.id=b.id)
然后delete all
再看A表里的数据就行了,呵呵,此方法仅供娱乐!
drop table tab2
go
create table tab1(a int,b datetime)
insert into tab1 select 12 , '2008-8-12'
insert into tab1 select 12 , '2008-8-12'
insert into tab1 select 12 , '2008-8-14'
insert into tab1 select 15 , '2008-01-12'
insert into tab1 select 15 , '2008-2-14'
insert into tab1 select 17 , '2008-2-5'
create table tab2(a int,b datetime)
insert into tab2 select 12 , '2008-8-12'
insert into tab2 select 12 , '2008-8-12' select *
from tab1
where not exists(select 1 from tab2 where tab1.a=tab2.a and tab1.b=tab2.b)
select * from A where not exists (select id from B)
select * from A where id not in(select id from b)