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

PHP

James Dawson
James Dawson
2,770 Points

REPORTING WITH SQL Challenge Task 1 of 1

Here is my query:

SELECT email AS obfuscated_email FROM customers WHERE REPLACE(email, "@", "<at>") = "<at>;

I'm not able to get this to work. I've tried changing little things to see if it made a difference, like the quotes around the target and the replacement, but I'm not getting anywhere with it. At this point, it seems as if I've tried everything. Obviously I'm missing something. Can someone help me out and tell me where I'm going wrong?

Also, I can't find SQL in the topic dropdown box, so I'm just putting this under PHP.

1 Answer

Benjamin Larson
Benjamin Larson
34,055 Points

Use the function blueprint provided in the teacher's notes (on the previous video) as a guide:

SELECT REPLACE(<original value or column>, <target string>, <replacement string>) FROM <table>;

In this case, you do not need a WHERE clause. Your REPLACE(email, "@", "<at>") should come immediately after the SELECT. Internally, the REPLACE function selects the email column, and so you don't have to select it again outside of that function. You can simply alias the result of the replacement.

James Dawson
James Dawson
2,770 Points

Benjamin, thank you. I understand it now.