SQL REPLACE
Replace every occurrence of some text.
Syntax
REPLACE(text, find, replace_with)
Example
Query (on the shop database used in the SQL course)
SELECT name, REPLACE(name, ' ', '_') AS slug FROM products LIMIT 4;
Result
| name | slug |
|---|---|
| Wireless mouse | Wireless_mouse |
| Mechanical keyboard | Mechanical_keyboard |
| USB-C hub | USB-C_hub |
| 27-inch monitor | 27-inch_monitor |
4 rows
Related
Learn it step by step in the free lesson Functions: Text, Numbers, Dates & CASE, with exercises that check your queries.