clear markdown compare help donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
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. 541820 fiddles created (11247 in the last week).

CREATE TABLE t1(id INT, name VARCHAR(8), surname VARCHAR(8)) SELECT 1 id, 'John' name, 'Zero' surname UNION ALL SELECT 2, 'Test' , 'First' UNION ALL SELECT 3, 'Mike' , 'Second' UNION ALL SELECT 4, 'James', 'Third' UNION ALL SELECT 5, 'Ivan' , 'Fourth' UNION ALL SELECT 6, 'John' , 'Zero'
 hidden batch(es)


CREATE TABLE t2(id INT, name VARCHAR(8), surname VARCHAR(8)) SELECT 1 id, 'John' name, 'Test0' surname UNION ALL SELECT 2, 'JACK' , 'First' UNION ALL SELECT 3, 'MIKE' , 'Second3' UNION ALL SELECT 4, 'Jame', 'Third4' UNION ALL SELECT 5, 'Evan' , 'Fourth' UNION ALL SELECT 6, 'John' , 'Zero'
 hidden batch(es)


SELECT t1.id, NULLIF(t1.name COLLATE utf8mb4_bin, t2.name COLLATE utf8mb4_bin) name, NULLIF(t1.surname COLLATE utf8mb4_bin, t2.surname COLLATE utf8mb4_bin) surname FROM t1 LEFT JOIN t2 ON t1.id=t2.id
id name surname
1 Zero
2 Test
3 Mike Second
4 James Third
5 Ivan
6
 hidden batch(es)