Hi,I have one query for different tables and all of them have different length which requires leading zero for the ID. Is it possible to use one query that will add leading zero to any table?
lets say first query is insert to tbl1_field1(CHAR 3) 001, then next query is insert to tbl2_field2(CHAR 4) 0001 then next is insert to tlb3_field3(CHAR 10) 0000000001. I am using php and mysql
You can do it in a SELECT query using LPAD function -
SELECT LPAD(id, 4, 0) FROM table;
the query will show a string like this - '0001'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With