Example 1
Replace a word in message bodies
Every occurrence of 'World' is replaced with 'SQL' in the output. The stored data is not modified — use UPDATE ... SET body = REPLACE(body, 'World', 'SQL') to persist the change.
Source table data Rows loaded before the example query runs.
Setup
CREATE TABLE messages (id INT, body VARCHAR(200));
INSERT INTO
messages (id, body)
VALUES
(1, 'Hello World'),
(2, 'World is great');Validated query Shared across supported engines.
SQL
SELECT
id,
REPLACE (body, 'World', 'SQL') AS updated_body
FROM
messages
ORDER BY
id;Expected result Returned rows for the shared example.
| id | updated_body |
|---|---|
| 1 | Hello SQL |
| 2 | SQL is great |
Output is identical across all engines.