Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
Delphi 7 Enterprise
|
Re: 2 SQL-Abfragen kombinieren
30. Jul 2008, 12:15
Ups, da habe ich was übersehen...
SQL-Code:
SELECT c.id, c.itemname, a.alevel, a.itemname,
s.anzahl AS Anzahl1, p.anzahl As Anzahl2
FROM tblcats c
INNER JOIN tblaccesslevels a
ON c.alevel = a.alevel
LEFT JOIN (SELECT parentcat, COUNT(*) AS anzahl
FROM tblsubcats
WHERE alevel <= 1
GROUP BY parentcat) s
ON c.id = s.parentcat
LEFT JOIN (SELECT parentsubcat, COUNT(*) AS anzahl
FROM tblpics
GROUP BY parentsubcat) p
ON s.id = p.parentsubcat
oder meinst du das vielleicht so...
SQL-Code:
SELECT c.id, c.itemname, a.alevel, a.itemname,
s.anzahl AS Anzahl1, p.anzahl As Anzahl2
FROM tblcats c
INNER JOIN tblaccesslevels a
ON c.alevel = a.alevel
LEFT JOIN (SELECT parentcat, COUNT(*) AS anzahl
FROM tblsubcats
GROUP BY parentcat) s
ON c.id = s.parentcat
LEFT JOIN (SELECT parentsubcat, COUNT(*) AS anzahl
FROM tblpics
GROUP BY parentsubcat) p
ON s.id = p.parentsubcat
WHERE c.alevel <= 1
|
|
Zitat
|