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

Hayley Martin
Hayley Martin
5,838 Points

How to put angle brackets around the data in a columns fields. Help!

The challenge i'm on is asking for angle brackets around the email address within the concatenated to_field but the related video has no information on how to do this. Help!

Hi Hayley,

Can you link to the challenge? This way the instructions can be reviewed.

In the future, if you click the "Get Help" button from within the challenge it should automatically link your question with that challenge.

4 Answers

Jacob Herrington
Jacob Herrington
15,835 Points

Without linking the the challenge, I can't be sure this is the answer they are looking for, but this should work in a real world scenario.

To my knowledge Teamtreehouse is using a MySQL instance for its courses in SQL. In MySQL you can concatenate (or join together) strings by using the CONCAT() function. So in this case, you want to concatenate: < result >. Here is an example of this happening:

SELECT CONCAT('<', email, '>')
FROM TableName
WHERE 1=1

So line by line we are saying

/*
Select and concatenate the following: <, the email field, and >
Get those from a table named TableName
Make sure 1 is equal to 1 (this is just here to show you that you can use a where clause as well)
*/

In other SQL set ups, it is not uncommon for the + operator to be used for concatenation. Feel free to do more research on the differences between RDMSs when you have a firm grasp of the content in the courses here on Treehouse.

Let me know if this doesn't solve your challenge, or answer your questions!

Andrew Horn
Andrew Horn
1,041 Points

reporting with SQL

Challenge Task 1 of 2

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.

the video doesnt make mention of angle brackets

I am also on the challenge outlined above by Andrew Horn about the angle brackets but the video made no mention of angle brackets so I am currently stuck and not sure how to proceed. Any help would be appreciated.

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