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. 2591550 fiddles created (45727 in the last week).

CREATE TABLE example ( id INT NOT NULL AUTO_INCREMENT Primary KEY, fullname VARCHAR(100) NOT NULL, email VARCHAR(100) NOT NULL, something VARCHAR(255) NOT NULL );
 hidden batch(es)


INSERT INTO example (id, fullname, email, something) VALUES (1, 'Name 1', 'name1@example.com', 'Something 1'), (2, 'Name 2', '', 'Something 2'), (3, 'Name 1', 'name1@example.com', 'Something 3'), (4, 'Name 3', 'name3@example.com', 'Something 4'), (5, 'Name 3', 'name3@example.com', 'Something 5'), (6, 'Name 4', '', 'Something 6');
 hidden batch(es)


SELECT GROUP_CONCAT(DISTINCT fullname), email FROM example WHERE email <> '' GROUP BY email UNION SELECT fullname, email FROM example WHERE email = '' ORDER BY email;
GROUP_CONCAT(DISTINCT fullname) email
Name 2
Name 4
Name 1 name1@example.com
Name 3 name3@example.com
 hidden batch(es)


SELECT GROUP_CONCAT(DISTINCT fullname), email FROM example GROUP BY email
GROUP_CONCAT(DISTINCT fullname) email
Name 2,Name 4
Name 1 name1@example.com
Name 3 name3@example.com
 hidden batch(es)