I have a query
SELECT SQL_CALC_FOUND_ROWS a.memberid, a.category_id, a.content, a.count_cid, a.importance
FROM tb_profilingdata a, tb_member b
WHERE a.memberid = b.memberid AND a.category_id IN ($catstr) AND a.memberid NOT IN ( $seen_txt) AND b.gender != '$gender'
ORDER BY a.memberid, a.category_id LIMIT $offset, 4500
Since my table is very large, i want to limit my query result to a certain limit. An also choose a dynamic offset, so that i can get random set of values everytime i run the query.
Till now i was calculating random offset based on total number of rows in the table through PHP. But if the offset value is larger than the total number of rows returned by the query, than the result would be empty.
So is there any way through which i don't have to load the entire table as well as set an appropriate random offset so that i can get random values?