Skip to content

Instantly share code, notes, and snippets.

@clebersonfalk
Last active April 26, 2019 13:27
Show Gist options
  • Save clebersonfalk/447db4199b69ef20ba2a1da91d73c671 to your computer and use it in GitHub Desktop.
Save clebersonfalk/447db4199b69ef20ba2a1da91d73c671 to your computer and use it in GitHub Desktop.
MySQL - Concat Not Null and Trim Separator on start and in the end
SELECT
TRIM(BOTH ';' FROM CONCAT_WS(';',`u`.`email`,`u`.`other_email`)) as emails,
`u`.`nome`
FROM
desk_20.`users` AS `u`
WHERE
(u.id_role = 2)# Admins
AND (u.status = 1)
AND (u.deleted = 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment