0

Considering XPT table containing the following values:

123, 443, 213, 124

I want to update it remove the last character of each number in order to get it like this:

12, 44, 21, 12
1

1 Answer 1

1

Use SUBSTRING() function:

SELECT SUBSTRING(t.value, 1, 2)
    FROM XPT t;

Or if you want to update:

UPDATE XPT t
    SET t.value = SUBSTRING(t.value, 1, 2);
Sign up to request clarification or add additional context in comments.

6 Comments

its possible using inner join this substring?
not working select substring (nuts3_resid_1amc,1,2) as source from dados inner join nuts02 on (dados.source= nuts02.id) where nuts3_resid_1amc='117'
ERROR: column dados.source does not exist
So you don't have a column source in table dados.. the error is pretty clear. @user2964140
Don't you have an ID column connects to nuts02 table ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.