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

Mike Booth
Mike Booth
2,035 Points

concatenating text question 1

Having trouble with this question, maybe I am not understanding the question completely, here is my code but it says the email is not in the correct format

SELECT first_name || " " || last_name || " " || email AS "To" FROM patrons;

4 Answers

Steven Parker
Steven Parker
231,128 Points

You didn't provide a link to the challenge, but I seem to recall that while the query was intended to fill a "To" line in an email, the alias name was actually "to_field".

And unless I'm confusing it with a difference challenge, I think the email field was supposed to be enclosed in angles ("<>"). If so, you'll need to include them with your literal concatenations.

If I'm not guessing right, provide a link to the course page and I'll take another look.

Mike Booth
Mike Booth
2,035 Points

You have the right question, it seems confusing though.

Question: In the library database there's a patrons table listing all the users of the library. The columns are id, first_name, last_name, address, email, library_id and zip_code. Generate a list of strings that are in the following format: Andrew Chalkley andrew@teamtreehouse.com. Concatenate the first name, last name and email address for all users. Alias it to to_field. This will be used in the "To" field in email marketing.

It looks like they want all 3, firstname, lastname, and email all in one field aliased To. That is what I have but I don't know how to add the <> to the email, maybe I missed it in the video.

Steven Parker
Steven Parker
231,128 Points

Oh good, I remembered it correctly. So the instructions do say to "Alias it to to_field", so that's your alias name right there. You can ignore the sentence about how it will be used in marketing.

And those angle characters you can just put in as string literals, just like you did with the spaces. In fact, the first one can be part of the same string as that last space.

Mike Booth
Mike Booth
2,035 Points

OK, I got the first <, but can't get the second one, here is my code now SELECT first_name || " " || last_name || "<" || email AS "to_field" FROM patrons;

I tried putting ||>|| after email but it threw an error, also I am not seeing an edit question link anywhere to change it to database

Steven Parker
Steven Parker
231,128 Points

Remember the quotes for literal strings, and no trailing concatenation operator —
so what would go after email would be :point_right: || ">"
And remember the space that goes with the first angle :point_right: " <"

And to expose the "edit question" choice you click on the little rectangle with the 3 dots in it.