How can you tell MYSQL about TRIM, the number of X characters starting from Back?

How do I write the following in MYSQL?

SELECT SUBSTRING ( - (1 TRAILING CHARACTER)) FROM table;

Basically the substring (value, 2) truncates the first letters. But I need to trim the last letters. I can’t use the substring (value, -4, 3) because I don’t know the length of the value.

Here's another example: SELECT * FROM table WHERE SUBSTRING ( - (4 TRAILING CHARACTER)) in (SELECT SUBSTRING ( - (1 TRAILING CHARACTER)) FROM table);

+2


source to share


1 answer


For example, to remove the last 2 characters from a string value

:



substring(value, 1, length(value) - 2)

      

+5


source







All Articles