Concept Flow - Concatenation with || operator
Start with two strings
Apply || operator
Combine strings end-to-end
Return concatenated string
The || operator takes two strings and joins them together into one longer string.
SELECT 'Hello' || ' ' || 'World' AS greeting;
| Step | Expression Evaluated | Intermediate Result | Action |
|---|---|---|---|
| 1 | 'Hello' || ' ' | 'Hello ' | Concatenate 'Hello' and space |
| 2 | 'Hello ' || 'World' | 'Hello World' | Concatenate previous result with 'World' |
| 3 | Return final result | 'Hello World' | Output the concatenated string |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| result | NULL | 'Hello ' | 'Hello World' | 'Hello World' |
Concatenation with || operator in PostgreSQL: - Syntax: string1 || string2 - Joins two strings end-to-end - Does not add spaces automatically - NULL on either side results in NULL - Useful for combining text columns or literals