Similar to other database systems, Oracle uses "|" to concatenate strings, which is the same as the plus sign "+" in MSSQLServer.
For example, execute the following SQL statement:
Copy codeThe Code is as follows:
SELECT 'employee ID is '| FNumber |' employee name is '| FName FROM T_Employee
WHERE FName IS NOT NULL
In addition to "|", Oracle also supports String concatenation using the CONCAT () function, such as executing the following SQL statement:
Select concat ('employee ID: ', FNumber) FROM T_Employee
If the connected value in CONCAT is not a string, Oracle will try to convert it to a string, such as executing the following SQL statement:
Select concat ('Age: ', FAge) FROM T_Employee
Unlike MYSQL's CONCAT () function, Oracle's CONCAT () function only supports two parameters and does not support concatenation of two or more strings. For example, the following SQL statement is incorrect in Oracle:
Select concat ('employee ID is ', FNumber,' employee name is ', FName) FROM T_Employee
WHERE FName IS NOT NULL
After running Oracle, the following error message is displayed:
Invalid Number of parameters
To splice multiple strings, you can use multiple CONCAT () functions for nesting. The preceding SQL statement can be rewritten as follows:
Copy codeThe Code is as follows:
Select concat ('employee ID is ', FNumber),' employee name is '), FName) FROM
T_Employee
WHERE FName IS NOT NULL