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 Reporting with SQL Working with Text Replacing Portions of Text

Adrian Patrascu
Adrian Patrascu
15,279 Points

REPLACE does not work for me

Has anyone tried the steps detailed in the challenge with the replace statement? Does it work for you? I have tried: SELECT email AS obfuscated_email FROM customers WHERE REPLACE(email,"@","<at>"); and it does not work...

Thank you for any input!

Adrian

3 Answers

Hi Adrian,

I've struggled a bit with the order of syntax in this course, but this is what worked for me in this challenge:

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

Hope that helps!

how come it replaced only the @ part from the whole email?. shouldn't you specify %@% in order for it to understand?

Adrian Patrascu
Adrian Patrascu
15,279 Points

Hi Cena,

Thank you for your help, it works this way! Very good note that indeed it was a struggle.

Thank you, Adrian

@sulaiman abouabdah It only replaced the @ part because that's the first value which was being replaced and the second value of <at> was its replacement. You don't need to specify like %@% just put in a REPLACE() function with the column you want changing and the value inside the column you want to change and the replacement value that it will be exchanged with.

:)