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

sailor winkelman
sailor winkelman
2,603 Points

Use REPLACE function with SELECT or WHERE?

I am doing the code challenge in Reporting with SQL titled "Replacing strings."

This is the question: In the customers table there's an email column. Write a query that will retrieve all email addresses but will replace the @ symbol with <at> so they all look like andrew<at>teamtreehouse.com. Alias it as obfuscated_email .

The code I attached doesn't work and I'm not sure why. I am not clear on when REPLACE( "@", "at") goes by SELECT versus by WHERE

4 Answers

Steven Parker
Steven Parker
231,261 Points

You forgot to share your code and link to the challenge, but the REPLACE will be part of the SELECT clause. And don't forget those angle brackets around the <at>. If I recall correctly, there's no need for a WHERE clause in this challenge.

Try fixing it before reading any further, but if you need the extra help...


:warning: SPOILER ALERT




SELECT REPLACE(email, "@", "<at>") as obfuscated_email FROM customers;

fuck yeah

Yu-Chien Huang
PLUS
Yu-Chien Huang
Courses Plus Student 16,672 Points

thats my code: SELECT REPLACE(email, "@", "<at>") AS obfuscated _email FROM customers;

sailor winkelman
sailor winkelman
2,603 Points

oh sorry. this was my code.

     SELECT REPLACE(email, "@", "at") AS obfuscated _email FROM customers;

it looks like i was just not putting the angle brackets around "at." I was getting something weird

as a hint so i couldn't see that it was just not returning exactly what they asked for.

thank you!