Last active
November 9, 2017 12:51
-
-
Save ateneva/5a2ef258c174fa9d7aecf52627dd5dab to your computer and use it in GitHub Desktop.
How do I concatenate strings with SQL?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*--------------------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