Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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