日期:2014-05-20 浏览次数:21107 次
CREATE TABLE [dbo].[a](
[id] [int] NULL,
[name] [nvarchar](50) NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[b](
[id] [int] NULL,
[name] [nvarchar](50) NULL
) ON [PRIMARY]
insert into a(id,name)
select 1,'张山'
union all
select 2,'李思'
union all
select 3,'王五'
insert into b(id,name)
select 1,'张山'
union all
select 2,'李思'
select id,name from a where exists(select top 1 1 from b where b.id=a.id)
select id,name from a where exists(select top 1 1 from b where b.id=a.id)
from p in a where b.Any(g=>g.id==p.id) select p