add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.

CREATE TABLE Table1
([Child] int, [Parent] int)
;
INSERT INTO Table1
([Child], [Parent])
VALUES
(1, 2),
(1, 3),
(2, 3)
;


3 rows affected
INSERT INTO table1 (child, parent)
SELECT DISTINCT t1.parent, NULL
FROM table1 t1
LEFT JOIN table1 t2
ON t1.parent = t2.child
WHERE t2.child IS NULL;


1 rows affected
SELECT *
FROM Table1
Child Parent
1 2
1 3
2 3
3 null