SQL Server / Oracle Concatenate Function


possible to concatenate more than two strings at a time in Oracle using ‘||’.

Let’s look at some examples. Assume we have the following table:

Table Geography

region_name store_name
East Boston
East New York
West Los Angeles
West San Diego

Example 1:

MySQL/Oracle:
SELECT CONCAT(region_name,store_name) FROM Geography
WHERE store_name = ‘Boston’;

Result:

‘EastBoston’

Example 2:

Oracle:
SELECT region_name || ‘ ‘ || store_name FROM Geography
WHERE store_name = ‘Boston’;

Result:

‘East Boston’

Example 3:

SQL Server:
SELECT region_name + ‘ ‘ + store_name FROM Geography
WHERE store_name = ‘Boston’;

Result:

‘East Boston’

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s