Add dot('.') after the 3rd character

Asked

Viewed 568 times

0

I have a registration with the original code of the product, but I need to put a . (dot) after the 3rd character.

Original code: 2022027

As it should be: 202.2027

Follows the structure of the table:

id
nome
descricao
aplicacao
imagem
codigo_original
data_cadastro
tbl_categoria_id
tbl_empresa_id

Thank you all from now on !

1 answer

1


You have to due the string as you want.
LEFT(original code,3) -> The first 3 characters
SUBSTRING(original code FROM 4) -> All other characters

Then you need to concatenate with the ".".:
CONCAT(LEFT(original code,3),'. ',SUBSTRING(original code FROM 4))

UPDATE tabela SET teste=CONCAT(LEFT(codigo_original,3),'.',SUBSTRING(codigo_original FROM 4))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.