Home > database >  SQL to find two different data table
SQL to find two different data table

Time:10-28

As shown in figure lookup table a and table b, and at the same time show the different data in

CodePudding user response:

 
The select a.s ku1, a.s l1, b.s ku2, b.s l2
A. the from list a
Full the join table b b on a.s ku1=b.s ku2
Where a.s l1 & lt;> B.s l2

CodePudding user response:

The
reference 1/f, started the first reply:
 
The select a.s ku1, a.s l1, b.s ku2, b.s l2
A. the from list a
Full the join table b b on a.s ku1=b.s ku2
Where a.s l1 & lt;> B.s l2


Moderators, leave some points to us,

CodePudding user response:

- & gt; Test data
If OBJECT_ID (' ta ') is not null drop table ta
If OBJECT_ID (' TB) is not null drop table TB
The create table ta (suk1 varchar (2), sl1 int)
The create table TB (suk2 varchar (2), sl2 int)
Insert into ta
Select 'a1, 1 union all
Union all select 'a2' 2
Select 'a3, 3
Insert into TB
Select 'a1, 1 union all
3 union all select 'a2'
Union all select a4, 4
Select the a5, 5
- & gt; Began to query
Select * from (
Select * from ta where not the exists (select * from TB where ta.621 suk1=TB. The suk2 and ta.621 sl1=TB. Sl2)) a
Full join (
Select * from TB where not the exists (select * from ta where ta.621 suk1=TB. The suk2 and ta.621 sl1=TB. Sl2))
bOn a.s uk1=b.s uk2 and a.s l1 & lt;> B.s l2
  • Related