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

Michael Schwartz
Michael Schwartz
909 Points

How do I write a query that will add <> to the data in a specific column in my query results?

I need the emails in my query results to be within the left and right arrow symbols.

2 Answers

Andrés Angelini
PLUS
Andrés Angelini
Courses Plus Student 22,744 Points

Hi Michael. If you want to get "<someemail@example.com>" as your query result you need to use concatenation with the || (double pipe) like this:

Supposing you have a column called "email" in a "customers" table...

SELECT "<" || email || ">" FROM customers;

You can learn more about it here: https://teamtreehouse.com/library/reporting-with-sql/working-with-text/-adding-text-columns-together

Hope it helps!

Andrew Winkler
Andrew Winkler
37,739 Points

Andres told you how to do it in oracle...

IN MS SQL Server it would be:

'<' + email + '>'

IN MySQL it would be:

CONCAT( '<', email, '>')

Andrés Angelini
Andrés Angelini
Courses Plus Student 22,744 Points

That's right! Thanks for the clarification Andrew. It's also explained in the course titled "Reporting with SQL", unit "Working with Text", step "Concatenating Text" (that's where the link I provided points to). I also recommend taking the "Database Foundations" course after this one to learn more about DML (Data Manipulation Language) and start getting your feet wet with DDL (Data Definition Language), which it's not taught in the other database courses (such as "SQL Basics").