开发者

MySQL Substring Grab all but last three characters

开发者 https://www.devze.com 2023-04-13 06:16 出处:网络
Basically, I am trying to find 开发者_运维百科the inverse of this command: substring(term, -3).Try this:

Basically, I am trying to find 开发者_运维百科the inverse of this command: substring(term, -3).


Try this:

SELECT SubStr(myColumn, 1, LENGTH(myColumn) - 3)
FROM MyTable

or

SELECT LEFT(myColumn, LENGTH(myColumn) - 3)
FROM MyTable


This should do it: SELECT SUBSTRING(term FROM 1 FOR LENGTH(term)-3)


If you need it to match in a where comparison you could use

WHERE somefield LIKE 'term___'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号