$sql='SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('.$str_tids.') AND n.status = 1 ORDER BY '.$order;
$sql_count='SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('.$str_tids.') AND n.status = 1';
$sql='SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('.$placeholders.') AND n.status = 1 ORDER BY '.$order;
$sql_count='SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('.$placeholders.') AND n.status = 1';
}
else{
$joins='';
$wheres='';
$args=array();
foreach($descendant_tidsas$index=>$tids){
$joins.=' INNER JOIN {term_node} tn'.$index.' ON n.nid = tn'.$index.'.nid';
$wheres.=' AND tn'.$index.'.tid IN ('.implode(',',$tids).')';