MySQL Substring Grab all but last three characters
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___'
精彩评论