select * from 主表 a
where exists(select 1 from 从表 where BiaoHao = a.BiaoHao
and shuliang1 = shuliang2)
where exists(select 1 from 从表 where BiaoHao = a.BiaoHao
and shuliang1 = shuliang2)
解决方案 »
- 死锁问题
- 2008 用linkserver访问自定义函数
- 请教行转列的问题
- 如何用SQL语句把某一值设为NULL?
- 求教:SQL Server 2005 新建Integration Services项目时出现未能加载“microsoft.datatransformationservices.wizards“信息。
- 白领30分,谁来领?
- 谁知道那儿有MSDE的下载!????????????????(在线等待)
- installshield问题:如何在安装程序中自动附加数据库到MS SQL Server 2000?
- 各位老大,请教一个sql server 200 插入的问题!
- 千万级数据删除
- ※简单的问题,进来接分~~~
- 有点难度的问题,高手请进~!!!!!!!!!!!!
create table t2(a varchar(10),c int,d int)insert t1
select '100','200'
union all select '200','2000'insert t2
select '100',1,1
union all select '100',1,2
union all select '200',2,2
union all select '200',3,3select * from t1 where a in(
select a from t2 where c<>d)
create table t1(a varchar(10),b varchar(10))
create table t2(a varchar(10),c int,d int)insert t1
select '100','200'
union all select '200','2000'insert t2
select '100',1,1
union all select '100',1,2
union all select '200',2,2
union all select '200',3,3select * from t1 where a in(
select a from t2 where c<>d)drop table t1
drop table t2/*
a b
---------
100 200
*/
from 主表 a join 从表 b on a.BianHao=b.BianHao
where b.shuliang1<>b.shuliang2
这样会查询出重复值其实我只是想找一种效率最高的查询方法,或解决方案
因为数据多
在shuliang1,shuliang2上没有索引!
from 主表 a join 从表 b on a.BianHao=b.BianHao
where b.shuliang1<>b.shuliang2
里面的select a.*改成
select distinct a.*
from 主表 a join 从表 b on a.BianHao=b.BianHao
where b.shuliang1<>b.shuliang2
行不行啊???