This is a classic pagination request. I suggest splitting it into two queries:
SELECT DISTINCT t1.id FROM t1 LEFT JOIN t2 ON ... LIMIT 5
Take these identifiers and put them in the following query:
SELECT t1.a, t2.b FROM t1 LEFT JOIN t2 ON ... WHERE t1.id IN (?,?,?,?,?)
hobodave
source share