Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases Reporting with SQL Working with Text Replacing Strings

chris Gougherty
chris Gougherty
1,682 Points

Issues understanding what is wrong with my code

Hello, I am having issues understanding what is wrong with this code. From my understanding i would assume this would be correct as i have renamed the column and have replaced the values as they need to be replaced based on the previous lessons. could i please get some help in understanding what is wrong with this code.

select email as obfuscated_email from customers where replace(email, "@", "<at>") = "<at>";

I have also tried the code

select replace(email, "@", "<at>") as obfuscated_email from customers where replace(email, "@", "<at>") = "<at>";

this code hasnt worked any better so i am unsure as to what is the problem

1 Answer

Steven Parker
Steven Parker
217,443 Points

Since the instructions say to replace all email addresses, you are not filtering the results and won't need a WHERE clause here. And to modify the column content, call the function as part of the SELECT clause:

SELECT replace(email, "@", "<at>") AS obfuscated_email FROM customers;