Is there a printf()-like formatting in MySQL?
I couldn't find a straightforward way in the documentation.
For example, how can I make something like:
SELECT STRFORMATFUNCTIONIMLOOKINGFOR("%03d", 17)
to get 017 ?
Is there a printf()-like formatting in MySQL?
I couldn't find a straightforward way in the documentation.
For example, how can I make something like:
SELECT STRFORMATFUNCTIONIMLOOKINGFOR("%03d", 17)
to get 017 ?
You can implement this kind of function by creating a new UDF (user defined function).E.g. see http://dev.mysql.com/doc/refman/5.1/en/adding-functions.html
see FORMAT() function:
mysql> SELECT FORMAT(12332.123456, 4);
returns '12,332.1235'
but it's only for formatting float numbers.