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

Zachary keller
Zachary keller
3,178 Points

The way the question is worded confuses me.

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.

says email format is wrong

2 Answers

Steven Parker
Steven Parker
231,269 Points

You forgot to show your query, but things to keep in mind while constructing one:

  • be sure to concatenate with spaces between the items
  • be sure the email area begins with a "<" character
  • also be sure the email ends with a ">" character
  • don't confuse the period that ends the instruction sentence with the pattern
  • the comments about how this will be used for marketing have no bearing on the task

If you still have trouble, add a comment showing your query code.

Zachary keller
Zachary keller
3,178 Points

thanks for fast reply, i check marked "show code" sorry. and i know this isn't right but how to do i fix? i need to alias email as <email>? then alias all of it to be to_field?

SELECT first_name || " " || last_name || email AS to_field FROM patrons

Steven Parker
Steven Parker
231,269 Points

I see you added the space between first and last names, but you still need both a space and the "<" character between the last name and the email, and a ">" after the email.

Zachary keller
Zachary keller
3,178 Points

like this?

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

because it doesnt say the error now but that means the error is between AS to_field FROM patrons

Steven Parker
Steven Parker
231,269 Points

The other characters need to be concatenated as literal strings, as you are doing with the spaces. You can have more than one character in a literal string (like a space with an angle: " <").

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

Can someone provide the correct code that worked? above one is not working either

Steven Parker
Steven Parker
231,269 Points

Close! But you have two concatenation operators ("||") with nothing between them.

And in future, start a fresh question instead of asking one as an "answer". :see_no_evil: