MySQL Forums
Forum List  »  German

COUNT() für Anzahl Produkte / rowspan
Posted by: Simon Maier
Date: April 11, 2012 02:37AM

Ich möchte mir die Produkt ID und den Preis anzeigen
lassen. Man beachte das es für ein produkt mehrere Preise gibt.


SELECT p.id AS partid,price
FROM prices lp
INNER JOIN parts p ON ( p.id = lp.parts_id )
WHERE
MATCH (p.herstellernr,text) AGAINST ("X" IN BOOLEAN MODE)
ORDER BY p.id,price


Das Ergebnis sieht dann etwa so aus:

10 - 150 eur
10 - 120 eur
10 - 100 eur
11 - ...
11 - ...
12..
13..
14..


Ich möchte dies per PHP in einer Tabelle Anzeigen.
Jetzt gibt es das Problem das ich wissen muss wie oft es fuer den selben Artikel Preise gibt.
In dem Beispiel oben sind es für den Artikel 10, 3 Preise.

Ich habe hier COUNT() versucht, jedoch endet das immer damit das ich nur noch ein Produkt wieder gegeben bekomme.

Die Anzahl benötige ich im voraus für rowspan/colspan

Sollte also so Aussehen:

10 - 150 eur - 3
10 - 120 eur - 3
10 - 100 eur -3
11 - ... - 2
11 - ... - 2
12.. - 1
13.. - 1
14.. - 1


Vielen Dank schonmal für die Hilfe

Options: ReplyQuote


Subject
Views
Written By
Posted
COUNT() für Anzahl Produkte / rowspan
1955
April 11, 2012 02:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.