MySQL && PostgreSQL截取substring

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(stringstartlength)  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;

你可能感兴趣的:(数据库,mysql,postgresql,数据库)