34,590
社区成员
发帖
与我相关
我的任务
分享
create table #t1(id int,content varchar(10))
create table #t2(bid int,id int)
create table #t3(cid int,id int)
insert into #t1 select 1,'内容1' union select 2,'内容2'
insert into #t2 select 1,1 union select 2,2
insert into #t3 select 1,1
select #t1.id,content,flag=case when cid is null then '否' else '是' end from #t1
inner join #t2 on #t1.id=#t2.id left join #t3 on #t1.id=#t3.id
id content flag
----------- ---------- ----
1 内容1 是
2 内容2 否
select TB.序号B,TA.内容,case when (select count(*) from TC where TB.编码=TC.编码)>0 then 1 else 0 end 标记,字段2,字段3... from TB
left join TA
on TB.编码=TA.编码