Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Reporting with SQL Working with Text Concatenating Text

Cosmin Iuga
Cosmin Iuga
2,352 Points

I'm so lost here. :(

So lost here. Please help:

SELECT first_name ||" "|| last_name ||" "|| email AS "Full Name", to_field AS "To" FROM patrons;

2 Answers

Sean T. Unwin
Sean T. Unwin
28,690 Points

In the previous lesson, right before this Challenge, there a quick note about using single vs double quotes. You need to understand when to use which. The key is to use single quotes for String literals, whereas double quotes are used for identifiers (I've found this is optional in many cases, at least with MS SQL Server and MySQL).

There is no reason to alias email as Full Name. Don't alias this field at all, actually.

The resulting String concatenation is to be aliased as to_field. This will be used as the value for the 'To' field when creating an email. We don't really care where the value is going to be used, we only need to know the alias to name it as.

We also need to include the angle brackets before and after the email address.

So pass this step:

  • change your double quotes to single when designating the spaces between the words
  • Remove the comma right before to_field and replace it with AS. It should look like AS to_field (Again, the double quotes are optional on the alias assignment)
  • Remove the AS "To"
  • Add the angled brackets to surround the email address.

I hope this helps and g'luck.

Pascal Breitrück
Pascal Breitrück
Courses Plus Student 3,206 Points

Ahh ok, nice2know . I have only tried the challeng without to check the course videos ;D . Thanks for the Information . I will change it .

Pascal Breitrück
PLUS
Pascal Breitrück
Courses Plus Student 3,206 Points

Hey my Friend try this. :D

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

Sean T. Unwin
Sean T. Unwin
28,690 Points

Single quotes should be used on String literals. This Challenge will pass with the doubles, but most database engines will fail when doing this in a real scenario. So we may as well get used to doing it correctly. :-)