The CONCAT function in Oracle is used to connect strings: Connect multiple strings: CONCAT(string1, string2, ...) Connect strings and column values: CONCAT('text', column name) is used Operator concatenates strings: 'string1' || 'string2' || ...Note: If any string is NULL, the result is NULL; up to 254 strings can be concatenated.
Usage of CONCAT function in Oracle
Introduction
CONCAT function is used to Concatenate two or more strings. It is a built-in function and does not need to be created or loaded.
Syntax
<code>CONCAT(string1, string2, ...)</code>
Among them:
Usage
The CONCAT function can be used in the following ways:
Concatenate multiple strings:
<code>SELECT CONCAT('Hello', ' ', 'World');</code>
Output: Hello World
Concatenating strings and column values:
<code>SELECT CONCAT('Employee Name: ', employee_name);</code>
Output: Employee Name: John Doe
Concatenate strings using operators:
The CONCAT function can also be used with operators, such as ||
:
<code>SELECT 'Hello' || ' ' || 'World';</code>
Output: Hello World
Additional Notes
Example
The following example demonstrates the use of the CONCAT function:
<code>SELECT CONCAT('First Name: ', first_name, ', Last Name: ', last_name) AS "Full Name" FROM employees;</code>
Output:
Full Name |
---|
First Name: John, Last Name: Doe |
First Name: Mary, Last Name : Jones |
The above is the detailed content of How to use concat function in oracle. For more information, please follow other related articles on the PHP Chinese website!