查詢:到`IN`添加條件查詢
SELECT * FROM #__content WHERE featured=1 and catid=$category_id or catid IN
(SELECT id FROM #__categories WHERE parent_id=$category_id)
Featured=1
作品只有在這裏catid=$category_id
。 catid IN (SELECT id FROM #__categories WHERE parent_id=$category_id)
開始輸出所有行,並且特徵= 1的位置在此處被忽略。如何增加featured=1
條件到catid IN
?
所以基本上它看起來像這樣由現在:
$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)";
你能舉一些例子你想要的輸出嗎? – Dipali