Page 1 of 1

UPDATING VALUES ON A MYSQL TABLE FIELD

Posted: Fri Aug 13, 2004 10:10 pm
by intercampus
What is the command to use in case i would like to change the value of one field on a mysql table by number on descending order, i mean, i have a field call "number" on the table called "data" how can i set the value of "number" to:
0
1
2
3
4
each time the script is executed

thanx

Posted: Fri Aug 13, 2004 11:16 pm
by anjanesh
Are you talking about auto_generate in Number field ? But the example that you've given is not in descending order.

Posted: Sat Aug 14, 2004 12:21 am
by feyd
* auto_increment ;)

Posted: Sat Aug 14, 2004 3:27 am
by arcanechaos
CREATE TABLE whatever (
whatever INT NOT NULL AUTO_INCREMENT,
etc..
etc..
PRIMARY KEY(something));

Posted: Sat Aug 14, 2004 1:03 pm
by arcanechaos
oh, and the mysql select looks like this:

Code: Select all

mysql_query("SELECT * FROM whatever ORDER BY whatever DESC");
// or ASCE for ascending

hi

Posted: Sat Aug 14, 2004 5:14 pm
by intercampus
the thing is that every time i add a data to the table it's put at the bottom that i fixed it sorting the table by date putting the latest data adition in the top of the table, what i need to do is to put number "0" to that data in one field and then changing the previous one to 1 the next to 2 etc being the case that before it was added that last data the now number 1 was 0, numer 2 was 1 etc.

Posted: Sat Aug 14, 2004 11:03 pm
by feyd
why make mysql do all that work, when you can just ask it to sort it with "ORDER BY" a lot easier?