August 22nd, 2000, 03:02 PM
Well hiya ppl I am studying to interact with MySQL bases using PHP 4. The problem is as follows: I need to use Update after editing a particular record. But I also need to supply a parameter to WHERE which would specify which record to update. So the question is is there any function in MySQL which handles the number of row(record)? so that I could use mysql_query("UPDATE mytable SET field1=var1, field2=var2 WHERE RECNO()=var3") but instead of RECNO was the function I'm asking about HUGE thanks in advance
August 23rd, 2000, 05:15 AM
As far as I know, no, MySQL doesn't maintain a row id to allow you to specify which record you wish to change. Anyway, that's a bad way to do it as there's no promise in a relational DB that there is any order to the data returned -- the third row returned could be 479th row entered (it probably won't be, but it _could_ be).
What you want to do is specify which row you want to update using some candidate (unique) key (probably the primary key, though only unique key would work). If you want to record the order you insert rows, add an auto_increment column to the table.