Concatenating strings
In this exercise and the ones that follow, we are going to derive new fields from columns within the customer
and film
tables of the DVD rental database.
We'll start with the customer
table and create a query to return the customers name and email address formatted such that we could use it as a "To" field in an email script or program. This format will look like the following:
Brian Piccolo <[email protected]>
In the first step of the exercise, use the ||
operator to do the string concatenation and in the second step, use the CONCAT()
functions.
This exercise is part of the course
Functions for Manipulating Data in PostgreSQL
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Concatenate the first_name and last_name and email
SELECT ___ ___ ' ' ___ ___ ___ ' <' ___ ___ ___ '>' AS full_email
FROM customer