How to change the location of the letters 5 and 6 in sql. For example:
word:weather new word:weatehr
You can try to use SUBSTRING
with LEN
function to make it.
CREATE TABLE T(
col varchar(40)
);
INSERT INTO T VALUES ('weather')
Query 1:
SELECT
col 'word' ,CONCAT(SUBSTRING(col,1,4),SUBSTRING(col,6,1),SUBSTRING(col,5,1),SUBSTRING(col,7,LEN(col) - 5)) 'new word'
FROM T
| word | new word |
|---------|----------|
| weather | weatehr |