Tsallaka zuwa abun ciki
Justice Tech School

SUBSTR, REPLACE and TRIM

SUBSTR cuts text, REPLACE swaps parts and TRIM removes spaces.

Example
SELECT SUBSTR(name, 1, 3) AS short, REPLACE(country, 'Nigeria', 'NG') AS code, TRIM('  x  ') AS t
FROM students LIMIT 3;

Result

short | code  | t
Ada   | NG    | x
Kof   | Ghana | x
Ami   | NG    | x

Exercise

Cut text.

(name, 1, 3)

Quiz Test

What does TRIM remove?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.