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 trialarthropod
2,792 PointsDatabase: SELECT first_name || " " || last_name AS "to", email AS "<email>" FROM patrons; -- I always get stuck here.
I'm trying to concatenate a string of values: first name and last name combined as "to", and the email address as "<Email>". I've tried any number of "AS" and "||" combinations without success.
3 Answers
Umesh Ravji
42,386 PointsHi Arthropod, you are on the right track. The issue you are having is that the email as required must be created by concatenating the <
and >
to either side.
SELECT first_name || ' ' || last_name || ' <' || email || '>' AS to_field
FROM patrons;
arthropod
2,792 PointsOK, now I'm confused. I got the response, "Bummer! Your query didn't retireve (that should be 'retrieve', by the way) the addresses in the correct format. Expecting 2532 2nd ST, San Diego, California 90222. USA not 2532 2nd ST, San Diego, California 90222 USA." I could swear that these two results are identical. My query string was SELECT street ||','||' '|| city ||','||' '|| state ||' '|| zip ||' '|| country AS address FROM addresses;
Umesh Ravji
42,386 PointsHi Arthropod, if you have any more issues, please create a new thread. Most other people will skip over this thread because it's already been answered and no one may help.
SELECT street ||','||' '|| city ||','||' '|| state ||' '|| zip ||'. '|| country AS address FROM addresses;
It's just the dot
missing after zip
, I've just added it inside the quotation marks.
SELECT street || ', ' || city || ', ' || state || ' ' || zip || '. ' || country AS address
FROM addresses;
You can also just have the comma and spaces together, it just makes it a little easier to read :)
arthropod
2,792 Pointsarthropod
2,792 PointsThank you, Umesh. I can only assume that to indicate the spaces between columns I was incorrectly using quotation marks rather than apostrophes (although quotation marks worked on the "Playground" page).