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

Melissa Snyder
Melissa Snyder
1,786 Points

How do you return angle brackets around an email address?

A concatenation Challenge Task is asking me to return first_name, last_name, email from the data base with angled brackets around the email address. How do I return a value with angled brackets around it?

3 Answers

Steven Parker
Steven Parker
231,261 Points

You'll combine literal strings and columns by concatenation. As John said, for the playground this is done with the || operator.

So you'll have something like this:

SELECT first_name || ' ' || last_name || ' <' || email || '>' AS combined_name FROM table_name;

The combined_name is an alias for the column heading, if they asked for a specific one just replace it. And of course replace table_name with the actual name of the table.

Casey Wilkinson
Casey Wilkinson
2,355 Points

Hey mellisa there is certainly more than one way to accomplish this but simple concatenation should do it. Something like the following:

SELECT '{'+Name+'}' FROM table

Hope this helps!

John Ham
John Ham
5,958 Points

Concatenation is certainly how you'd do this.

In SQL, you'd use || to concatenation several strings together.

Use Casey's example and replace the + operator with || and see how that works for you.