Add point ('.') after 3rd character

0

I have a registry with the original product code, however I need to put one. (dot) after the 3rd character.

Original code : 2022027

How should it be : 202.2027

The table structure follows:

id
nome
descricao
aplicacao
imagem
codigo_original
data_cadastro
tbl_categoria_id
tbl_empresa_id

Thank you all right away!

    
asked by anonymous 15.04.2016 / 20:00

1 answer

1

You have to give the string as you wish. LEFT (original_code, 3) - > The first 3 characters
SUBSTRING (original_code FROM 4) - > The remaining characters

Then need to concatenate with ".":
CONCAT (LEFT (original_code, 3), '.', SUBSTRING (original_code_FROM 4))

UPDATE tabela SET teste=CONCAT(LEFT(codigo_original,3),'.',SUBSTRING(codigo_original FROM 4))
    
15.04.2016 / 20:30