php - MySQL - count number of rows AFTER query -
i have query running on site looks rows don't have particular attribute. although have sequential numbers row numbers, actual result have gaps in primary keys. turns out difficult explain, i'll try , add code!
here's part of statement, rest unimportant:
...where thought_deleted = 0 , thought_id <= (select max(thought_id) rmt_thoughts order thought_id) - $start order thought_date_created desc limit $number
$number , $start values passed query using php. part want change , part. instead of looking thought_id values less particular id, want select if each thought_deleted = 0 row has sequential id. hope makes sense!
i'm assuming need either a) make kind of alias counts number of rows, , sort or b) sort of limit thingy looks @ values want. either way, i've been googling while pretty exhausted , stuck. has seen before?
thanks guys :)
sparkles*
apparently want kind of pagination. specify offset using limit <offset>, <limit>
instead of limit <limit>
.
for example, retrieve rows 1..5 use limit 0, 5
, next 5 rows use limit 5, 5
.
in case want use limit $start, $number
assuming $start zero-based.
Comments
Post a Comment