Skip to content
Advertisement

postgresql remove last 4 characters from text values

I have a table with only one column that has multiple text values. All of them end with same 4 characters that I would like to remove. Could anyone, please, help me with a query for that?

I’ve already tried ‘replace’

SELECT REPLACE(ticker, 'USDT', '') FROM tickers;

It appears to do what I want, but it doesn’t update my data in a table.

Advertisement

Answer

You need an update statement

UPDATE tickers
SET ticker = REPLACE(ticker, 'USDT', '');
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement