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

What's wrong?

My code keeps saying not the correct format for email

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

You will need to provide more information (e.g. Course, link to challenge, code used, errors received, etc) in order for us to be able to help you troubleshoot. :dizzy:

2 Answers

Hi Paul,

You're missing the angle brackets around the email which need to be concatenated and the alias should be to_field

The query that Alexander posted is pretty close to the correct query except that literal angle brackets should be in the strings instead of the html entities.

SELECT first_name || " " || last_name || " <" || email || ">" AS to_field FROM patrons;
Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Thanks, Jason Anello

You are answer solves the challenge.

But you know what is strange:

The answer that is printed in console:

to_field
Andrew Chalkley
Dave McFarland
Alena Holligan
Michael Poley

Please check that out. It is definitely not like it is asked in Task :

Andrew Chalkley <andrew@teamtreehouse.com>

Where is e-mail field?

I know you probably don't know, because you didn't create the challenge, but still, don't you think that something is not right?

Just first name and last name printed but not e-mail.

Running your code prints e-mail correctly in Workspaces.

But mine with HTML &lt braces does not work in Workspaces... However does prints right answer in Challenge ...

For me it looks like that there are different version of SQL programs, that print results in Workspace and in console ...

You're welcome.

The tester is working correctly but there is a problem with the output.

The staff was informed in this question here: https://teamtreehouse.com/community/reporting-with-sql-challenge-task-1-out-of-2

The database results are not properly escaped when they are sent back to the browser for display. The angle brackets need to be replaced with the html entities code so that the browser does not treat the emails as html tags.

If you inspect that output area using your browsers dev tools you'll see that the email is there. But because it's interpreted as an invalid tag, nothing shows up on the page for it.

This is why you saw the correct output when you used html entities in your query. It wasn't right for the database but when it got sent back to the browser for display it was correct.

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

Jason Anello

Thanks for the detailed explanation.

You are right, now I see braces and e-mail in Developer Tools after posting your query.

Interesting problem. It is good to know.

Hi Paul!

Please show a little bit more information regarding this issue. Error codes, code, etc. No one can really provide assistance based on the information you've given them.

SELECT first_name || " " || last_name || " " || email AS "To" FROM patrons;

This is what I get when I run the query

To Andrew Chalkley andrew.chalkley@teamtreehouse.com Dave McFarland dave.mcfarland@teamtreehouse.com Alena Holligan alena.holligan@teamtreehouse.com Michael Poley michael.poley@teamtreehouse.com

And it tells me Your query needs didn't retireve the emails in the correct format.

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

That is the link to challenge:

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

I also don't know why it does not work.

That is the task:

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.

I tried also adding "<" and ">" signs, does not work ...

SELECT first_name || " " || last_name || " &lt" || email || "&gt" AS to_field FROM patrons;

Although the result looks good just like task says :(:

to_field
Andrew Chalkley <andrew.chalkley@teamtreehouse.com>
Dave McFarland <dave.mcfarland@teamtreehouse.com>
Alena Holligan <alena.holligan@teamtreehouse.com>
Michael Poley <michael.poley@teamtreehouse.com>