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

Do I need to escape the "<at>" part of the code?

Reporting with SQL challenge where there is a customers database with email and I am to return the email address replacing the @ with <at>. I write the code as follows SELECT email, REPLACE (email, "@", "<at>") FROM customers; but when it returns it ran as though I wrote the code SELECT email, REPLACE (email, "@", "") FROM customers. Why is the "<at>" disappearing when I run the sql statement?

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Shawn,

No, you don't need to escape the <at>. Your code isn't returning the proper string for a few reasons:

  1. First is a syntax error. It looks like you have placed a comma between "SELECT email" and "REPLACE." (No comma should go here).

  2. You have used the table email twice. This kind of relates back to #1. Once you delete the comma, you need to delete the email after SELECT. You are calling on the table inside of the parenthesis.

  3. I'm not sure if it was just the copy and paste into the question, but you are missing the part of the query that asks you to alias it to ...

So, in the end, you have to SELECT and REPLACE then alias (AS) the return FROM the database.

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

I hope this makes sense. Keep Coding! :dizzy:

Thanks Jason! I figured it out eventually... seems to be the way I do things, try, try, try, give up and ask for help, try, try, try, succeed. Thanks for the answer though I do appreciate it!