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 Strings

how to replace

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

whats worong with this code to replace value nanes?

3 Answers

Gabriel Plackey
Gabriel Plackey
11,064 Points
SELECT REPLACE(email, "@", "<at>") AS obfuscated_email FROM customers;

You don't need WHERE or email after select, as you are selecting the REPLACE fuction which has the column or value in the first spot. For the challenge you were also missing the alias

ok but when alias a name it need to be like this : old name AS new name ?

how come that i now need to write AS obfuscated_email FROM customers; without the old name?

Gabriel Plackey
Gabriel Plackey
11,064 Points

Well you're not changing the name of the column or anything, with replace you are changing every instance of "@" to "<at>" in the values of the email column. Since the replace function is already selecting the email column you then only need AS <alias name>, and not repeat the name of column before as.