clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2591678 fiddles created (45712 in the last week).

select version();
version()
5.7.29
 hidden batch(es)


CREATE TABLE foo_1 ( foo_x INTEGER NOT NULL, foo_y INTEGER NOT NULL, foo_2 INTEGER NOT NULL, foo_3 VARCHAR (25) NOT NULL, PRIMARY KEY (foo_x, foo_y) ); INSERT INTO foo_1 VALUES (1, 1, 2, 'foo_3_val_1'), (1, 2, 7, 'foo_3_val_2'), (1, 3, 8, 'foo_3_val_3'), (1, 4, 9, 'foo_3_val_4');
 hidden batch(es)


SELECT * FROM foo_1;
foo_x foo_y foo_2 foo_3
1 1 2 foo_3_val_1
1 2 7 foo_3_val_2
1 3 8 foo_3_val_3
1 4 9 foo_3_val_4
 hidden batch(es)


CREATE TABLE foo_2 ( foo_x INTEGER NOT NULL, foo_y INTEGER NOT NULL, foo_2 INTEGER NOT NULL, foo_3 VARCHAR (25) NOT NULL, PRIMARY KEY (foo_x, foo_y) ); INSERT INTO foo_2 VALUES (1, 1, 2, 'foo_3_val_1'), (1, 2, 7, 'foo_3_val_2'), (1, 3, 8, 'foo_3_val_3'), (1, 4, 9, 'foo_3_val_4');
 hidden batch(es)


SELECT * FROM foo_2;
foo_x foo_y foo_2 foo_3
1 1 2 foo_3_val_1
1 2 7 foo_3_val_2
1 3 8 foo_3_val_3
1 4 9 foo_3_val_4
 hidden batch(es)


INSERT INTO foo_1 VALUES (1, 5, 24, 'foo_3_val_5');
 hidden batch(es)


SELECT * FROM foo_1;
foo_x foo_y foo_2 foo_3
1 1 2 foo_3_val_1
1 2 7 foo_3_val_2
1 3 8 foo_3_val_3
1 4 9 foo_3_val_4
1 5 24 foo_3_val_5
 hidden batch(es)


INSERT INTO foo_2 SELECT * FROM foo_1 WHERE (foo_x, foo_y) NOT IN (SELECT foo_x, foo_y FROM foo_2);
 hidden batch(es)


SELECT * FROM foo_2;
foo_x foo_y foo_2 foo_3
1 1 2 foo_3_val_1
1 2 7 foo_3_val_2
1 3 8 foo_3_val_3
1 4 9 foo_3_val_4
1 5 24 foo_3_val_5
 hidden batch(es)