$query = $db->query("SELECT $dotadd1 t.*, p.rate FROM {$tablepre}threads t $dotadd2
LEFT JOIN {$tablepre}posts p USING(tid, dateline)
WHERE t.fid='$fid' $filteradd AND $displayorderadd
ORDER BY t.displayorder DESC, t.$orderby $ascdesc
LIMIT ".($filter == 'digest' || $filter == 'type' ? $start_limit :
$query = $db->query("SELECT $dotadd1 t.*, p.rate FROM {$tablepre}threads t $dotadd2
LEFT JOIN {$tablepre}posts p USING(tid, dateline)
WHERE t.fid='$fid' $filteradd AND $displayorderadd
ORDER BY t.displayorder DESC, t.$orderby $ascdesc
LIMIT ".($filter == 'digest' || $filter == 'type' ? $start_limit :