Adding "0" to a returned value from Mysql in the Grid Application

Hello,

I have numbers (INT) stored in my mysql table. My Grid application will return those numbers, but I need them to be formatted like this (just in the Grid application, not in the database) :

001
010
100

So, I need the number to always be 3 digits in length. The database will return a digit, either single or up to 3 digits, but I alway need enough leading zeros added to the digit in order to fit the 3 digit requirement.

I found that but it’s only for SQL Server :
SELECT right(replicate(‘0’,2) + convert(varchar(3),<ColumnName> ) ,2) from <Tablename>

I would like the same result for Mysql…

Thank you very much for your help !

Re: Adding “0” to a returned value from Mysql in the Grid Application

SELECT lpad(field,3,‘0’) As fieldName FROM table

Regards,
Scott.

Re: Adding “0” to a returned value from Mysql in the Grid Application

Thank you very much. It work !
I would like to include the LPAD() fonction in another SELECT, because i would like to use the CONCAT() fonction with LPAD() like : SELECT CONCAT(…(LPAD(…))
Is this possible ?

Thank you :slight_smile:

Re: Adding “0” to a returned value from Mysql in the Grid Application

You can stack function calls in a select with no problem. Give it a try :slight_smile:

Regards,
Scott.