kingberrill of SQL
6/11/2017 - 11:13 AM



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

-- REPLACE(state, <target>, <replacement>)

SELECT * FROM addresses 
    WHERE REPLACE(state, "California", "CA") = "CA";
-- replace @ synbol with <at> from email column
SELECT REPLACE(email, "@", "<at>") AS "obfuscated_email" FROM customers ;

--- In all of the reviews, replace the text "public relations" with "PR"
SELECT REPLACE(review, "public relations", "PR") || " - " || username AS "Review" from reviews;