Introduction
Concatenation
4. Concatenation operator ||
Simple text functions
How to modify strings
Revision

Instruction

Okay, let's start off. First, we'll need a new operator: ||. These two vertical bars are the concatenation operator, i.e. they join two or more text values (or strings, which is another name for text values). If you write the following:

SELECT first_name || last_name
FROM slogan;

the result for first_name = 'Kate' and last_name = 'Gordon' will be KateGordon, all of this in a single column. Quite simple, right?

Of course, we want the first and the last name separated with a space. Here is how you do it:

SELECT first_name || ' ' || last_name
FROM copywriter;

Note that you use apostrophes for specific constant text values (a space in our example: ' '), but you don't use apostrophes for column names (first_name, last_name). The operator || can be used as many times as you need in a single query.

Exercise

Show each copywriter first_name and last_name in one column separated with a single space.

Console

Code editor

Result

TableConsole