I am not sure if you understood my question correctly. Therefore, I can explain a little. I have a customer table needed for testing with a different number (whether or not it is). So this is the script:
customer_db
+----+------------+ | ID | NUMBER | +----+------------+ | 1 | 0812345678 | +----+------------+ | 2 | 0812345678 | +----+------------+ | 3 | 0812345678 | +----+------------+ . . . |100 | 0812345678 |
According to the table. I ran this script:
UPDATE customer_db SET number = FLOOR(0812345678 + rand()*1000000);
Doing this. I expect the field to remain in the same format with the leading “081” and a random remaining 6 digits. But it is not . The table will be as follows:
+----+------------+ | ID | NUMBER | +----+------------+ | 1 | 812246797 | +----+------------+ | 2 | 816548798 | +----+------------+ | 3 | 815787898 | +----+------------+ . . . |100 | 813454687 |
This is 9 digits instead of 10. Because there is no "0". What to do to remain the leading "0" after random.
php mysql sql-update random
Wilf Sep 23 '14 at 2:04 on 2014-09-23 14:04
source share