Databases Reporting with SQL Working with Text Concatenating Text

please help!

ive got this

SELECT first_name || " " || last_name || " " || email AS to_field FROM customers;

I felt like i was close but obviously not close enough, could somebody help me with the answer for this question? driving me mad this is!

4 Answers

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi there, Sandeep Padda ! Indeed, you are very close. First, you are selecting from the wrong table. The table is named "patrons", but you are selecting from "customers". I know they mean the same thing in English, but SQL doesn't know that :smiley:

Secondly, it actually wants that email to appear in angle brackets just like they have in the example, so somewhere in there you need to concatenate on those brackets. Hint: somewhere in your statement you will need...

" <" || email || ">"

I will leave the placement and the renaming of the table up to you, but you've got this!

Hope this helps! :sparkles:

i stil dont get it, ould you please help with the answer

Jennifer Nordell
Jennifer Nordell
Treehouse Staff

Sandeep Padda I'm sorry the hints weren't enough. I will do my best to explain:

SELECT first_name || " " || last_name || " <" || email || ">"  AS to_field FROM patrons;

This line will select the first name and last name of each person in the patrons table. Note that the table is named patrons and not customers as you have written. Assuming I am in that table and my email address is me@example.com, in a field aliased as to_field, you would find this printed:

Jennifer Nordell me@example.com

This even includes the angle brackets or "<" and ">". Hope this clears things up! :sparkles:

ok i finally got it! couldnt figure out where to put the angle brackets but this worked

SELECT first_name || ' ' || last_name || ' <' || email || '>' AS to_field FROM patrons;

thank you very much for your help Jennifer!