kingberrill of SQL
6/1/2017 - 9:36 PM



--SUBSTR(<value or column>, <start>, <length>)

-- Create smaller strings from larger piece of text you can use the SUBSTR() funciton or the substring function.

SELECT SUBSTR(<value or column>, <start>, <length>) FROM <table>;

-- SUBSTR(<value or column>, <start>, <length>)

SELECT name, SUBSTR(description, 1, 30) || "..." AS short_description, price FROM products;

-- this will output firct character from description column

SELECT SUBSTR(first_name, 1, 1) AS "Initial" FROM users;

--- From the actors, truncate names greater than 10 charactor with ... e.g. William Wo...
SELECT SUBSTR(name, 1, 10) || "..." AS "Actor" from actors;