PostgreSQL
SELECT
substring(cm_cust_no,1,4) AS cust_no_short
FROM
"cus"
WHERE
cm_term != 'abc'
AND cm_term != 'def'
AND cm_term != '123'
AND cm_term != 'ar'
MySQL
SUBSTRING(string, start, length) OR
SUBSTRING(string FROM start FOR length)
SELECT SUBSTRING("SQL Tutorial", 5, 3) AS ExtractString;
SELECT SUBSTRING(cus_code, 1,4) AS ExtractString FROM biz_cus;
或者 Left
SELECT LEFT(CustomerName, 5) AS ExtractString FROM Customers;