Jump to content


Photo

modify a field throughout a table


  • Please log in to reply
3 replies to this topic

#1 wompus

wompus
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationNY

Posted 10 April 2003 - 05:58 PM

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
Free the West Memphis 3 http://wm3.org

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 10 April 2003 - 06:55 PM

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
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 wompus

wompus
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationNY

Posted 10 April 2003 - 07:11 PM

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.
Free the West Memphis 3 http://wm3.org

#4 wompus

wompus
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationNY

Posted 10 April 2003 - 09:24 PM

Nevermind. I got it. I changed the type of field to an integer. Now it sorts correctly without 0s infront of numbers.
Free the West Memphis 3 http://wm3.org




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users