0
I am making a query to get all the projects that are being executed:
SELECT p.id FROM projetos p WHERE p.status LIKE 'Execução'
An example of the result:
COD00012347
COD00012348
COD01212349
COD00123410
COD00123411
I would like to apply a regex so that my result is only the numbers (disregarding the 0
to the left):
12347
12348
1212349
123410
123411
I tried to apply the function SUBSTRING()
but I haven’t had good results. I’m learning SQL yet, what I can do??
But what was the problem you encountered with the substring function? Ever thought about using the RIGHT function?
– anonimo
@anonymity to qnt of zeros may vary for example.
– Gabriel Hardoim
If you only want the last 6 characters, maybe
RIGHT(coluna, 6)
work.– Sam
@anonimo still this 6 may vary. I edited the question to show a more specific result.
– Gabriel Hardoim
If you need that separate number, it wouldn’t be better to store it in a different column?
– Woss
@anonymity does not have written permission.. how can I do this?
– Gabriel Hardoim