sql字符串截取

技术博客 (300) 2023-09-16 10:44:53

使用SUBSTR实现字符串截取:

SUBSTR(string, Nstart, Nend) AS stringnew

比如:

(1)截取字符串前10位

string = '20190604080910'

Nbegin = 1

Nend = 10

SUBSTR(string, Nbegin, Nend) AS stringnew

则:

stringnew = '2019060408'

 

(2)截取字符串后6位

string = '20190604080910'

Nbegin = 9

Nend = 14

SUBSTR(string, Nbegin, Nend) AS stringnew

则:

stringnew = '080910'

THE END

发表回复