Skip to content

Instantly share code, notes, and snippets.

@linxlad
Forked from vielhuber/README.MD
Created July 1, 2016 10:13
Show Gist options
  • Save linxlad/f6ff5ae71ab2b58d429ece69d2ce1eaa to your computer and use it in GitHub Desktop.
Save linxlad/f6ff5ae71ab2b58d429ece69d2ce1eaa to your computer and use it in GitHub Desktop.
PostgreSQL: Concat two strings intelligently
SELECT CONCAT(
first_name,
(CASE WHEN (first_name IS NULL OR first_name = '') THEN '' ELSE ', ' END),
last_name
) FROM members
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment