Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a simple format (MySQL)

Tags:

sql

mysql

The goal

Convert 99999999 into 99999-999.

The problem

I do not know the syntax.

What I already thought about

I was thinking to useFORMAT() function — but I'm working with INT instead of DECIMAL.

My query

Select city.ZipCode As zipCode
From app_cities As city
Where city.Id = 1

So, that's it. Someone has any idea to me?

like image 770
Guilherme Oderdenge Avatar asked Jul 08 '26 01:07

Guilherme Oderdenge


1 Answers

Use INSERT()

select insert(ZipCode , 6, 0, '-') As zipCode
from app_cities As city
where Id = 1

SQLFiddle demo

like image 167
juergen d Avatar answered Jul 09 '26 22:07

juergen d



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!