Milano Milano - 1 year ago 119
SQL Question

How to remove substring from the end of the string

How can I remove a specific substring if this substring is at the end of the string?

In one column, there is

at the end - value = 'str***ing***' and I want to strip
so the value would be 'str***ing'. I want to delete this substring only from the end of the string.

This is what I have done so far:

I though about
but it wants coordinates but the string can be different sizes.

UPDATE final_table SET parametre = ??? WHERE parametre like '%***'

Answer Source

use substr(your_column , -num)

substr(, -6)

UPDATE final_table SET parametre =  substr(parametre,1, length(parametre)-3) 
WHERE parametre like '%***'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download