AdBlock Detected!
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.
SQL Concatenate Function |
|
SQL > SQL String Functions >
Concatenate
The Concatenate function combines multiple character strings together. Each database provides its own way(s) to do this:
SQL string concatenation joins column values and literal strings into a single result — the syntax differs by database: CONCAT() for MySQL/Oracle, || for Oracle/PostgreSQL, and + for SQL Server.
SyntaxThe syntax for CONCAT( ) is as follows: The above syntax concatenates str1, str2, str3, and any other strings together. Each str can be a column name, or it can be a literal character string (meaning a sequence of characters enclosed by two single quotes), or just white space. Please note the Oracle CONCAT( ) function only allows two arguments -- only two strings can be put together at a time using this function. However, it is possible to concatenate more than two strings at a time in Oracle using '||'. The syntax for using '||' to concatenate is as follows: The syntax for using '+' to concatenate is as follows: ExamplesWe use the following table for our examples. Table Geography
Example 1: Use CONCAT function to concatenateMySQL/Oracle:
Result: 'EastBoston'
Example 2: Use '||' to concatenateOracle:
Result: 'East Boston'
Example 3: Use '+' to concatenateSQL Server:
Result: 'East Boston'
Frequently Asked Questions
|
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.