1 Sep 2005 01:22
Re: ID based on position?
Jasper Bryant-Greene <jasper <at> bryant-greene.name>
2005-08-31 23:22:03 GMT
2005-08-31 23:22:03 GMT
Gustav Wiberg wrote: > Hi there! > > Is there any function in PHP that gives an ID from a MySQL-db based on > which position the record has in the table? > > Let's say, there's a table like this: > > 1. Record1 ID 33 > 2. Record2 ID 76 > 3. Record3 ID 100 > > If I know position 2, I want to get ID 76. Is the only way to loop > through the recordset? Why don't you use MySQL's LIMIT clause? Example: SELECT * FROM myTable LIMIT 1,1 will retrieve the second row from myTable. You could combine that with WHERE clauses or whatever. Note that the LIMIT syntax is LIMIT [rowcount] or LIMIT [offset],[rowcount] and the offset starts at 0. -- -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ If you find my advice useful, please consider donating to a poor student! You can choose whatever amount you think my advice was(Continue reading)
RSS Feed