Skip to content

Instantly share code, notes, and snippets.

@ateneva
Last active November 9, 2017 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ateneva/5a2ef258c174fa9d7aecf52627dd5dab to your computer and use it in GitHub Desktop.
Save ateneva/5a2ef258c174fa9d7aecf52627dd5dab to your computer and use it in GitHub Desktop.
How do I concatenate strings with SQL?
/*--------------------MySQL--------------------------------------*/
select
Concat('2017','-Feb') as TwoStrings,
Concat('2017','-','Feb') as MultipleStrings
----------------------SQL Server-----------------------------------
select
Concat('2017','-Feb') as TwoStrings,
Concat('2017','-','Feb') as MultipleStrings
----------------------PostgreSQL-----------------------------------
select
'2017' || '-Feb' as TwoStrings,
'2017' || '-' || 'Feb' as MultipleStrings
---------------------Vertica---------------------------------------
select
--concat in vertica is only applicable to two strings
Concat('2017','-Feb') as TwoStrings
Concat('2017',Concat('-', 'Feb')) as MultipleStrings
'2017' || '-' || 'Feb' as MultipleStrings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment