How can you tell MYSQL to TRIM the X number of characters, beginning from the Back?
Posted
by Tim
on Stack Overflow
See other posts from Stack Overflow
or by Tim
Published on 2010-04-10T02:06:08Z
Indexed on
2010/04/10
2:13 UTC
Read the original article
Hit count: 281
How do I write the following in MYSQL?
SELECT SUBSTRING(value - (1 TRAILING CHARACTER)) FROM table;
Basically substring(value, 2) trims the first letters. But I need to trim the last letters. I can't use substring(value, -4, 3) because I don't know the length of the value.
Here's another example:
SELECT * FROM table WHERE SUBSTRING(value - (4 TRAILING CHARACTER)) in (SELECT SUBSTRING(value - (1 TRAILING CHARACTER)) FROM table);
© Stack Overflow or respective owner