欢迎投稿

今日深度:

SQL存在一个表而不在另一个表中的数据,sql不在

SQL存在一个表而不在另一个表中的数据,sql不在


select a.id,a.oacode,a.custid,a.custname,a.xsz,a.salename,a.communicationtheme,a.communicationproperty,a.communicationtime,a.productmanager,'' creator,a.creator oaCreator,a.createdate,case when a.oastate='正常结束' then 3 else 0 end status from reception_flow a 
where  (1=1)
and (a.oastate='正常结束' or a.oastate='反馈中' or a.oastate='已反馈')
and (select count(1) as num from technology_support s where s.oacode=a.oacode)=0


怎用sql语句查询:在一个表中存在而另一个表中不存在的第一条记录?

select top 1 *
from tb2
where id not in (select [index] from tb1)
order by id
 

sql查询一个表里的数据在另一个表是否存在

insert into tableA
select * from tableB b where not exists(select 1 from tableA a where a.id = b.id)
insert into tableA
select * from tableB b
left join tableA a on a.id = b.id
where a.id is null
----用 not exists来判断,left join ,其中条件为唯一性主键
 

www.htsjk.Com true http://www.htsjk.com/shujukunews/2818.html NewsArticle SQL存在一个表而不在另一个表中的数据,sql不在 select a.id,a.oacode,a.custid,a.custname,a.xsz,a.salename,a.communicationtheme,a.communicationproperty,a.communicationtime,a.productmanager, creator,a.creator oaCreator,a.creat...
评论暂时关闭