Using Limit with subquery

I have a master table and a detail table and want to perform a query returning only a certain number of master records that can be processed as a limit so I can paginate the full set. So if each master has a different number of detail records, putting a limit on the query limits it based on the number of detail records which is the total number of records retrieved.

In this case, do I need to do a master query first and then process all the detail queries based on the master return?

Hope that makes sense, if not let me know.

that would work quite well, except you have a bit more coding to do in the application to “merge” the two result sets

Thanks for the input. I have decided to go that route and it so far works just fine and gives me more control and seems to process very efficiently as well. I am doing a master query and then a single detail query after building an IN clause with the first query key values and then will process the merge in PHP. Thanks again.