0
Ich möchte 12 Beiträge aus posts
Tabelle auswählen. Wenn es keine 12 von ihnen gibt, muss ich die fehlende von parchive
Tabelle auswählen.Falsche Verwendung von UNION und ORDER BY
$stmt = $db->query("SELECT * FROM posts where status='public' and user='public' order by inde asc limit 12 offset " . $offset);
$count1 = $stmt->rowCount();
if ($count1 < 12){
$diff = 12 - $count1;
$stmt = $db->query("SELECT * FROM posts where status='public' and user='public' order by inde asc limit 12 offset " . $offset .
" union select * from parchive where status='public' order by date desc limit " . $diff);
}
Fehler:
General error: 1221 Incorrect usage of UNION and ORDER BY in...
Jede Hilfe?
es funktioniert. Danke vielmals. – bonaca