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

Mary Urban
Mary Urban
6,321 Points

Concatenate objective for Reporting with SQL

I don't know what I am doing wrong with this statement for this objective - tells me I am not returning the email in the correct format

Thanks

SELECT first_name || " " || last_name AS "FULL NAME", email AS "to_field" FROM patrons;

Hi Mary,

Can you link to the challenge that you're on?

Like what Jason Anello said, we need to know which code challenge you are on to be able to help you :)

Please provide a link to the challenge and the task you are on, the question of the task, etc.

Thank you for your patience! ~alex

2 Answers

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

That is probably the link to challenge

https://teamtreehouse.com/library/reporting-with-sql/working-with-text/concatenating-text

The problem with your solution is quite simple.

The e-mail you have to write is

Andrew Chalkley <andrew@teamtreehouse.com>

The e-mail you obtain with your SQL query, that is

SELECT first_name || " " || last_name AS "FULL NAME", email AS "to_field" FROM patrons;

Is the following e-mail

Andrew Chalkley andrew@teamtreehouse.com

So you see the difference ? You forgot to add brackets "<", ">" on both sides.

Hi Alexander,

As a heads up, I think the "Get Help" button on database code challenges isn't working which is why I think we're seeing so many questions without links to the challenge.

Also, there's one more problem with the query. 2 separate columns are being returned here but the challenge wants the name and email all concatenated into 1 column.

Mary Urban
Mary Urban
6,321 Points

Thanks for the responses, and here is my link:

https://teamtreehouse.com/library/reporting-with-sql/working-with-text/concatenating-text

But yes, I think you are right Jason, I clicked right on the challenge so I was hoping that would link directly to it, but I guess it didn't, thanks for bringing this up, as this seemed to happen to me last week as well.

When I try to string the email like this it gives me the error below.

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

>SQL Error: near "||": syntax error

If I write >SELECT first_name || " " || last_name AS "FULL NAME" || " " || <email> AS "to_field" FROM patrons;

As suggested, by Alexander, I still get the same error - I didn't know I was supposed to use brackets in the query around email???

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

You have to do it in one field, like Jason said and alias that as to_field

You also have to put quote marks around brackets

If you feel still lost to find solution

check the community answere here

https://teamtreehouse.com/community/whats-wrong-74