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.

Databases Reporting with SQL Working with Text Concatenating Text

Michael Martin
Michael Martin
8,647 Points

This statement works in SQL Playground, aliasing three values as to_field, what am I doing wrong with this question?

select first_name || " " || last_name || " " || "<" || email || ">" as "to_field" from patrons where first_name = "Andrew"

What is wrong with this query? if I change the variables around, it works just fine in the playground, am I misunderstanding what to alias it to/as?

Michael Martin
Michael Martin
8,647 Points

I got this to work, didn't understand question.......................

1 Answer

You've got a "" in between the last_name and the '<' where there shouldn't be one. In the playground it wont matter as it will just bring back the results. However, in the task it is asking for specific results so it will see that extra space and automatically think it's wrong.

try and compare your task to this. I have tested the code below and know this works.

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

:)

Michael Martin
Michael Martin
8,647 Points

I figured it out, I was looking at the question wrong, but I really appreciate your response