SQL has one table but not the data in another table. SQL is not
Select. id,. OA code,. custid,. custname,. xsz,. salename,. communicationtheme,. communicationproperty,. communicationtime,. productmanager, ''creator,. creator oaCreator,. createdate, case when. oastate = 'normal termination' then 3 else 0 end status from exception_flow a where (1 = 1) and (. oastate = 'normal termination' or. oastate = 'feedback 'or. oastate = 'feedback') and (select count (1) as num from policy_support s where s. OA code =. OA code) = 0
How to use an SQL statement to query the first record that exists in one table and does not exist in the other table?
Select top 1 *
From tb2
Where id not in (select [index] from tb1)
Order by id
SQL queries whether data in one table exists in another table
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
---- Use not exists to judge, left join, where the condition is the unique primary key