Databases Reporting with SQL Working with Text Concatenating Text

Domenic Crump
Domenic Crump
2,707 Points

How do you concatenate 3 columns?? I'm so confused, it's Challenge Question 1 Reporting w/ SQL

Trying to generate a list of strings with first_name, last_name, and email and alias it to the "to_field"

2 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 42,592 Points

You can keep concatenating as many columns as you want

SELECT column1 || ' ' || column2 || ' ' || column3 AS my_new_column FROM table;

Here's another example with answer provided. If that is what you are working on a lot of people get tripped up on the <> surrounding the email.

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 42,592 Points

The concatenation operator (for SQLite) is ||. So for example you can concatenate two columns with a space between them as follows:

SELECT column1 || ' ' || column2 AS my_new_column FROM table;
Domenic Crump
Domenic Crump
2,707 Points

Hey Kris, thanks so much for helping out! I understand how to join 2 columns, but what would it look like when if someone were to join 3?