OPTION1: Do some code to achieve this. You will need to use the result of one query (and it's rowset) to produce the internal result of the other.
you can throw the recordid into the internal query from the external one - which will give you your results your after.
some pseudocode (do not use example only):
PHP Code:
$resultouter = $db->query_read("
SELECT id, username
FROM subscriptionlog
LEFT JOIN user ON (user.userid = subscriptionlog.userid)
WHERE subscriptionid = 6 AND status = 0 AND usergroupid = 2
");
while( $rowouter = $db->fetch_array($resultouter){
$resultinner = $db->query_read("
SELECT username
FROM subscriptionlog
LEFT JOIN user ON (user.userid = subscriptionlog.userid)
WHERE subscriptionid = 1 AND status = 0 AND usergroupid = 2
AND subscriptionlog.id = " . $rowouter['id'] . "
");
while( $rowinner = $db->fetch_array($resultinner){
// do something here with the query result? populate an array?
}
$db->free_result($resultinner);
}
$db->free_result($resultouter);
OPTION2: You could also look at INNER_JOIN and OUTER_JOIN complex queries, it may provide some assistance. Visit mysql site and lookup INNER_JOIN.
OPTION 3: You could look at SELECT ... WHERE field IN(SELECT ... WHERE) queries.
hope this helps.