To make a question simplier let's suppose we are having two tables with few columns and one-to-many relation...
firstwith fieldsid,some_fieldandsecond_id.secondwith fieldsid,parent_id
First I do
SELECT first.id, first.some_field, second.id, second.parent_id
FROM first INNER JOIN second ON first.second_id = second.id
WHERE some_field="some_val"
But after that I need to get first.id, first.some_field, second.id from join of two tables where parent_id is among values in respective column of result of the above query.
Is that can be done with one query? Or (on PHP side) I need to take column in result set and do something like the following?
SELECT first.id, first.some_field, second.id, second.parent_id
FROM first INNER JOIN second ON first.second_id = second.id
WHERE parent_id IN (<many_ids_here>)