Introduction
Concatenation with || operator joins two or more text pieces into one string. It helps combine words or data easily.
string1 || string2 || ... || stringN
'Hello' || ' ' || 'World'
first_name || ' ' || last_name'City: ' || city || ', Country: ' || country
SELECT 'John' || ' ' || 'Doe' AS full_name;
|| operator do in PostgreSQL?|| operator is used to combine text strings in PostgreSQL.|| in PostgreSQL?|| to join strings, so 'Hello' || ' ' || 'World' is correct.users with columns first_name = 'Jane' and last_name = 'Doe', what is the result of this query?SELECT first_name || ' ' || last_name AS full_name FROM users;
first_name, a space, and last_name using ||, so the output includes a space between names.SELECT first_name || last_name FROM users WHERE id = 1;
first_name is 'John' and last_name is NULL for user with id 1.|| results in NULL.last_name is NULL, first_name || last_name returns NULL, not 'JohnNULL'.street, city, and zipcode columns with commas and spaces in between. Which query correctly handles NULL values so the result never becomes NULL?SELECT street || ', ' || city || ', ' || zipcode AS full_address FROM addresses;
|| with NULL returns NULL, so we must replace NULLs with empty strings using COALESCE.COALESCE(column, '') to avoid NULL results.Pass the test and this pattern moves unknown