Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

General Discussion

II am concatenating three columns and are struggling with the email in the following format <jacques@kil.co.za>.

When I concatenate and have to change the format of for instance the email address, how do I go about. I retrieved the three columns as I should but missing the correct format.

6 Answers

Patrik Horváth
Patrik Horváth
11,085 Points

give link to task :)

nut you can Combine multiple Data Sources by using " || " maybe code below helps :)

SELECT a_name || " " || a_last_name || " " || adress AS UserData FROM table;

in your case

SELECT "<" || email || ">" FROM table;

Thank you Patrik

The Question is: 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.

Below is my query with the results which looks correct to me yet it is saying my query is incorrect.

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

to_fields Andrew Chalkley andrew@teamtreehouse.com. Dave McFarland dave@teamtreehouse.com. Alena Holligan alena@teamtreehouse.com. Michael Poley michael@teamtreehouse.com.

Patrik Horváth
Patrik Horváth
11,085 Points

Problem is "." delete it from end :) i had same issiu :D when i was in this challange

where ?

<" || email || ">."   <- HERE REMOVE "."

to_fields Andrew Chalkley andrew@teamtreehouse.com. Dave McFarland dave@teamtreehouse.com. Alena Holligan alena@teamtreehouse.com. Michael Poley michael@teamtreehouse.com.

Sorry I am still not winning should I only remove the . from the end. This is hwat my query is like and still no luck.

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

Patrik Horváth
Patrik Horváth
11,085 Points

Your SQL Query is good :) but AS to_field no to_fields :), so you think good but misstyping :) keep moving on :)

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

Thank you Partik, I appreciate the help. Need to pay more attention to what is required.