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 trialGeorge Barrie
1,162 PointsIssue with Less Than sign. Reporting with SQL challenge Task 1 of 2.
The challenge:
https://teamtreehouse.com/library/reporting-with-sql/working-with-text/concatenating-text
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.
Query that I believe is the answer:
''' SELECT first_name|| " <"||email||">" AS "To" FROM patrons; '''
Results from above query:
To
Andrew
Dave
Alena
Michael
Bummer! Your query needs didn't retrieve the emails in the correct format.
Note: If a space is placed behind the less than sign the query retrieves the following:
''' SELECT first_name|| " < "||email||">" AS "To" FROM patrons '''
To
Andrew < andrew.chalkley@teamtreehouse.com>
Dave < dave.mcfarland@teamtreehouse.com>
Alena < alena.holligan@teamtreehouse.com>
Michael < michael.poley@teamtreehouse.com>
Bummer! Your query needs didn't retrieve the emails in the correct format.
Does anyone know what I am doing wrong? Or is this a bug?
Thanks in advance for your help.
1 Answer
jcorum
71,830 PointsGeorge, you left out the last_name, a space between the name and the first angle bracket, among others. Try this:
SELECT first_name || " " || last_name || " <" || email || ">" AS "to_field" FROM patrons;
George Barrie
1,162 PointsGeorge Barrie
1,162 PointsThat worked! Thanks!