wompus Posted April 10, 2003 Share Posted April 10, 2003 I just started learning mysql today so this might sound stupid. I have a field in a table called id. I would like to add a the number 0 before each value in this field. How can i do this throughout the whole table? Thanks Quote Link to comment Share on other sites More sharing options...
shivabharat Posted April 10, 2003 Share Posted April 10, 2003 One way would be to concatenate \"0\" to the id whenever u insert the data like say u have like this eg $id has 100 $id = \'0\'.$id; echo $id ; this will display 0100 Quote Link to comment Share on other sites More sharing options...
wompus Posted April 10, 2003 Author Share Posted April 10, 2003 OK. I use this field to sort entries in an online journal. I was fine till i hit 100 entries. Now when I sort in descending order, entry #100 ends up with entry #10. If I could put an extra zero infront of every entry number currently in the table it will fix this. I have no problem entering data into this table in the correct format. My question is, can I add the number 0 before every value in a specified column or do i have to edit each one using phpmyadmin. Quote Link to comment Share on other sites More sharing options...
wompus Posted April 10, 2003 Author Share Posted April 10, 2003 Nevermind. I got it. I changed the type of field to an integer. Now it sorts correctly without 0s infront of numbers. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.