Query:
SELECT * FROM #__content WHERE featured=1 and catid=$category_id or catid IN
( SELECT id FROM #__categories WHERE parent_id=$category_id )
Featured=1 works only here catid=$category_id. The place where starts this catid IN outputs all rows and featured=1 is ignored at this place. How to add
( SELECT id FROM #__categories WHERE parent_id=$category_id )featured=1 condition to catid IN?
So basically it looks like this by now:
$query = "SELECT * FROM #__content WHERE featured=1 and catid=$category_id";
$query2 = "SELECT * FROM #__content WHERE catid IN
( SELECT id FROM #__categories WHERE parent_id=$category_id )";
You need to add parentheses to force the order of evaluation that you need:
Since
ANDhas higher precedence thanOR, the expression without the parentheses was true when(featured=1 and catid=$category_id)was true, orcatidwas in theINlist specified by the subquery.