Oracle/SQL CONCAT Function is used to concatenate two strings to form one string. The return type of SQL CONCAT Function is a string. Syntax and examples of Oracle CONCAT Function are mentioned below.
SQL CONCAT Function Syntax
SELECT CONCAT(string_1, string_2) FROM table_name;
string_1 and string_2 are the strings to be concatenated.
SQL CONCAT Function Example – Use with SQL SELECT Statement
Oracle CONCAT Function is used with the SQL SELECT Statement.
For example, the Oracle CONCAT Function query below returns a string by concatenating two strings.
SELECT CONCAT('TECH', 'HONEY') "Oracle CONCAT Function" FROM dual;
The above Oracle CONCAT Function query returns ‘TECHHONEY’.
Note: We have aliased CONCAT(‘TECH’, ‘HONEY’) as Oracle CONCAT Function
SQL CONCAT Function – Concatenating Strings having Whitespaces Example
SQL CONCAT Function can also be used to concatenate strings having whitespaces.
For example, the Oracle CONCAT Function query below returns a string after joining two string, one with spaces at the end.
SELECT CONCAT('TECH ', 'HONEY') FROM dual;
The above Oracle CONCAT Function query returns ‘TECH HONEY’.
SQL CONCAT Function – Concatenating String Having Whitespaces Example
SQL CONCAT Function can also concatenate strings which have white space in between the words.
For example, the below Oracle CONCAT Function query returns a string after joining two string having whitespace at end and in between strings.
SELECT CONCAT('ORACLE ', 'SQL PLSQL') FROM dual;
The above CONCAT Function query returns ‘ORACLE SQL PLSQL’.