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 Link to comment https://forums.phpfreaks.com/topic/334-modify-a-field-throughout-a-table/ 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 Link to comment https://forums.phpfreaks.com/topic/334-modify-a-field-throughout-a-table/#findComment-1077 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. Link to comment https://forums.phpfreaks.com/topic/334-modify-a-field-throughout-a-table/#findComment-1078 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. Link to comment https://forums.phpfreaks.com/topic/334-modify-a-field-throughout-a-table/#findComment-1080 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.