简体   繁体   中英

Get values from database from row to row

I'm trying to select values from row 85 in this while loop. So all values that are selected in the database before row 85 should be excluded in the while loop, and everyone above 85 should be "Do Something" with.

Any suggestions how to achieve this?

$to_emails = mysql_query("SELECT * FROM ".$DBprefix."users WHERE workouts > 10");

while ($to_email = mysql_fetch_array($to_emails)) {
    // Do Something        
}

Look here:

To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

SELECT * FROM tbl LIMIT 95,18446744073709551615;

http://dev.mysql.com/doc/refman/5.0/en/select.html

So try something like this:

$to_emails = mysql_query("
          SELECT * FROM ".$DBprefix."users 
          WHERE workouts > 10
          LIMIT 85,18446744073709551615");

Try like

$to_emails = mysql_query("SELECT * FROM ".$DBprefix."users WHERE workouts > 10 LIMIT 85,200");

Or even try like(May be it works)

$to_emails = mysql_query("SELECT * FROM ".$DBprefix."users WHERE workouts > 10 LIMIT 85,(SELECT COUNT(*) FROM ".$DBprefix."users");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM