Ich verwende eine Tabelle für Kategorien und Inhalt.Limit basierend auf Count
Wert von Kategorien in pid Feld ist 0.
Zum Beispiel:
Beispiel Tabelle
--------------------------
id | pid | name
--------------------------
1 | 0 | Some catgory 1
--------------------------
2 | 1 | Some content of first category
--------------------------
3 | 1 | Other content of first cat
--------------------------
4 | 0 | Second category
--------------------------
5 | 0 | Category number 3
--------------------------
6 | 5 | Content of category 3
--------------------------
7 | 4 | Content of 2 cat
--------------------------
8 | 5 | Content of 3 cat
--------------------------
9 | 5 | Other Content of 3 cat
--------------------------
10 | 5 | One more content of 3 cat
--------------------------
11 | 4 | Content of 2 cat
--------------------------
12 | 5 | One more content of 3 cat
--------------------------
13 | 1 | First cat content
--------------------------
14 | 1 | Other content of 1 cat
Wie in einer Abfrage alle Kategorien und 10 Inhaltselemente zu bekommen?
10 Inhalt Artikel pro Kategorie? oder insgesamt – andrewjs
10 Inhaltselemente und alle Kategorien. – Mirgorod
like (SELECT * FROM Tabelle WHERE pid! = 0 LIMIT 0,10) + (SELECT * FROM Tabelle WHERE pid = 0) ergibt 10 Inhaltselemente und alle Kategorien in Tabelle – Mirgorod