Code :
CREATE TABLE #table1 (id int, nom varchar(50)) CREATE TABLE #table2 (id int, id_table1 int, champ varchar(50)) INSERT #table1 (id, nom) Values (1, 'nom1'), (2, 'nom2'), (3, 'nom3'), (4, 'nom4'), (5, 'nom5'), (6, 'nom6'), (7, 'nom7') TRUNCATE TABLE #table2 INSERT #table2 (id, id_table1, champ) Values (1, 1, 'champ1'), (2, 1, 'champ2'), (3, 2, 'champ3'), (4, 3, 'champ4'), (5, 3, 'champ5'), (6, 3, 'champ6'), (7, 5, 'champ7'), (8, 5, 'champ8'), (9, 5, 'champ9'), (10, 7, 'champ10'), (11, 7, 'champ11'), (12, 7, 'champ12'), (13, 7, 'champ13'), (14, 7, 'champ14') SELECT * FROM #table1 SELECT * FROM #table2 SELECT * FROM #table1 a JOIN #table2 b on b.id_table1 = a.id SELECT * FROM #table1, #table2 Where #table1.id != #table2.id_table1 SELECT * FROM #table1 a LEFT JOIN #table2 b on b.id_table1 = a.id WHERE b.id IS NULL
|