Find records which don't match | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Find records which don't match

So I have 3 tables (with columns) : 1. Kat(ID/Kind) 2. Tur1(ID/Date/Kind) 3. Tur2(ID/Date/Kind) I'd like to like sum tables Tur1 & Tur2 and find out which records from those two are different from the table Kat I was trying to do it in Microsoft Access but don't know the constructor, how to write this command in sql.

2nd Dec 2018, 6:52 PM
Mateusz Legend
Mateusz Legend - avatar
2 Answers
0
Give an example to understand the case. I think that saying sum you mean the union of these tables. Moreover different on which columns ? only Kind ? select * from ( Select ID, Date, Kind from Tur1 union Select ID, Date, Kind from Tur2) m where not exists ( select 1 from Kat k where k.Kind = m.Kind); --- Checked in oracle db With Tur1(ID,"Date",Kind) as ( Select 1, TO_DATE('01/12/2018', 'dd/mm/yyyy'), 3 from dual union all Select 2, TO_DATE('01/12/2018', 'dd/mm/yyyy'), 1 from dual union all Select 3, TO_DATE('01/12/2018', 'dd/mm/yyyy'), 8 from dual ), Tur2(ID,"Date",Kind) as ( Select 1, TO_DATE('01/12/2018', 'dd/mm/yyyy'), 3 from dual union all Select 2, TO_DATE('01/12/2018', 'dd/mm/yyyy'), 4 from dual union all Select 3, TO_DATE('01/12/2018', 'dd/mm/yyyy'), 18 from dual ), Kat(ID,Kind) as ( Select 1, 4 from dual union all Select 2, 1 from dual ) select * from (select * from Tur1 union select * from Tur2) m where not exists ( select 1 from Kat k where k.Kind = m.Kind);
3rd Dec 2018, 6:46 AM
Prokopios Poulimenos
Prokopios Poulimenos - avatar
+ 1
Yes. Union of those two. Thanks a lot it Will work :)
3rd Dec 2018, 8:05 AM
Mateusz Legend
Mateusz Legend - avatar