![]() In the following example, we use CONCAT function to concatenate a string with a NULL value. SELECT CONCAT (first_name, ' ', last_name) AS "Full name" FROMĬustomer Code language: SQL (Structured Query Language) ( sql ) The following statement concatenates values in the first_name and last_name columns of the customer table in the sample database. The following SELECT statement uses the CONCAT function to concatenate two strings into one: SELECT CONCAT ( 'CONCAT', ' ', 'function') Code language: SQL (Structured Query Language) ( sql ) We will see it in detail in the following section. Unlike the concatenation operator ||, the CONCAT function ignores NULL arguments. In this case, you need to mark the array with the VARIADIC keyword. The CONCAT function treats each array element as an argument. ![]() It means that the CONCAT function accepts an array as the argument. A string in this context means any of the following data types: char, varchar, or text. The argument needs to be convertible to a string. The CONCAT function accepts a list of arguments. ) Code language: SQL (Structured Query Language) ( sql ) The following illustrates the syntax of the CONCAT function: CONCAT(str_1, str_2. Since version 9.1, PostgreSQL introduced a built-in string function named CONCAT to concatenate two or more strings into one. The following statement concatenates a string with a NULL value: SELECT 'Concat with ' || NULL AS result_string Code language: SQL (Structured Query Language) ( sql ) ![]() ![]() To concatenate two or more strings into one, you use the string concatenation operator || as the following example: SELECT 'Concatenation' || ' ' || 'Operator' AS result_string Code language: SQL (Structured Query Language) ( sql ) Introduction to PostgreSQL CONCAT function Summary: in this tutorial, we will show you how to use the PostgreSQL CONCAT and CONCAT_WS functions to concatenate two or more strings into one. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |