一条SQL语句?
1.两个表A、B
A有a,b,c三个字段;B有d,e,f三个字段;A.a与b.d字段类型一样,A.a中包括B.d,找出B.d=A.a中的d,e,f数据,A.a数据大于B.d?
救解?
[解决办法]
select d, e, f
from B
where B.d in (select a from A)
[解决办法]
create table A( a int, b int, c int)insert A select 1,1,1insert A select 2,2,2insert A select 3,3,3create table B( d int, e int, f int)insert B select 0,0,0insert B select 1,1,1insert B select 4,4,4--A.a=B.d的数据select * from Bwhere exists(select * from A where A.a=B.d)
[解决办法]
select B.* from B join A on B.d=A.a
[解决办法]
1.两个表A、B
A有a,b,c三个字段;B有d,e,f三个字段;A.a与b.d字段类型一样,A.a中包括B.d,找出B.d=A.a中的d,e,f数据,A.a数据大于B.d?
救解?
----------
select * from B
where exists(select 1 from A where a=B.d)
[解决办法]
declare @A table(a varchar(10),b int,c int)insert @A select 'a',1,2insert @A select 'b',3,4declare @B table(d varchar(10),e int,f int)insert @B select 'b',5,6select b.* from @B b join @A a on b.d=a.a/*d e fb 5 6*/