update A set tem=(case when exists(select 1 from t2 where deptcode like A.deptcode+'_%') then null else 1 end) from t2 A
select depcode,(select count(*) as a from #t where depcode like '%' + a.depcode + '%' and a.depcode <> depcode ) from #t a
select (case when exists(select 1 from t1 where deptcode like A.deptcode+'_%') then null else 1 end) as tem,deptcode from T1 A
select depcode,(select count(*) as a from #t where depcode like a.depcode + '_%' --and a.depcode <> depcode ) from #t aselect depcode,(select count(*) as a from #t where len(replace(depcode,a.depcode,'')) <> len (depcode) and a.depcode <> depcode ) from #t a
J老师可以的:select (case when exists(select 1 from t1 where deptcode like A.deptcode+'_%') then null else 1 end) as tem,deptcode from T1 A
最简单:select (select 1 from t1 where deptcode like A.deptcode+'_%') tem,deptcode from T1 A
select distinct a.deptid from t a join t b on a.deptid<>b.deptid where CHARINDEX(a.deptcode,b.deptcode)>=1找到 2 3 4 7 9列需要改为null
select (select max(1) from #t where depcode like a.depcode + '_%' -- and a.depcode <> depcode ) as tem ,depcode from #t a
看错题目,哈哈 正好反了哈哈,还是要case的,对不起! select (select 1 from t1 where deptcode like A.deptcode+'_%') tem,deptcode from T1 A
update #t set deptid=null where deptid in (select distinct a.deptid from t a join t b on a.deptid<>b.deptid where CHARINDEX(a.deptcode,b.deptcode)>=1 )
大力 你那个 select (select 1 from t1 where deptcode like A.deptcode+'_%') tem,deptcode from T1 A 有点问题 子查询返回的值多于一个j老师 和playyuer(心上人) 老大的可以的
from #t
where depcode like '%' + a.depcode + '%'
and a.depcode <> depcode
)
from #t a
select depcode,(select count(*) as a
from #t
where depcode like a.depcode + '_%'
--and a.depcode <> depcode
)
from #t aselect depcode,(select count(*) as a
from #t
where len(replace(depcode,a.depcode,'')) <> len (depcode)
and a.depcode <> depcode
)
from #t a
from t a join t b on a.deptid<>b.deptid
where CHARINDEX(a.deptcode,b.deptcode)>=1找到 2 3 4 7 9列需要改为null
from #t
where depcode like a.depcode + '_%'
-- and a.depcode <> depcode
) as tem ,depcode
from #t a
正好反了哈哈,还是要case的,对不起!
select (select 1 from t1 where deptcode like A.deptcode+'_%') tem,deptcode from T1 A
set deptid=null
where deptid in (select distinct a.deptid
from t a join t b on a.deptid<>b.deptid
where CHARINDEX(a.deptcode,b.deptcode)>=1 )
你那个
select (select 1 from t1 where deptcode like A.deptcode+'_%') tem,deptcode from T1 A
有点问题 子查询返回的值多于一个j老师 和playyuer(心上人) 老大的可以的