I want to extract the first (not last three) characters of a string from a table like:
Code
--------
CREF182
CXEF7U8
CEF7U8
CF777
How can I perform a query that will discard the last three characters of the string in a result so it shows something like:
Code
--------
CREF
CXEF
CEF
CF
I'm thinking this should be the Opposite of mysql RIGHT function? Any suggestions?
Try this one...
Syntax
SELECT SubStr(myColumn, 1, LENGTH(myColumn) - 3)
FROM MyTable
Example
SELECT SubStr(code, 1, LENGTH(code) - 3)
FROM MyTable
How about:
SELECT REVERSE(SUBSTR(REVERSE(Code), 4)) as Code from YourTable;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With