Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mySql Query

Status
Not open for further replies.

crysus

Programmer
Mar 15, 2004
1
DE
hello!

hey i have the following tables:

CREATE TABLE tartikel (
kArtikel int(10) unsigned NOT NULL default '0',
tKategorie_kKategorie int(10) unsigned NOT NULL default '0',
cArtNr varchar(20) default NULL,
cName varchar(255) default NULL,
fVKBrutto float(6,2) default NULL,
fVKNetto float(6,2) default NULL,
...
PRIMARY KEY (kArtikel),
KEY tArtikel_FKIndex1 (tKategorie_kKategorie)
) TYPE=MyISAM;

CREATE TABLE tliefartikel (
kLiefArtikel int(10) unsigned NOT NULL default '0',
tArtikel_kArtikel int(10) unsigned NOT NULL default '0',
tLieferant_kLieferant int(10) unsigned NOT NULL default '0',
fEKBrutto float(6,2) default NULL,
fEKNetto float(6,2) default NULL,
PRIMARY KEY (kLiefArtikel),
KEY tLiefArtikel_FKIndex1 (tLieferant_kLieferant),
KEY tLiefArtikel_FKIndex2 (tArtikel_kArtikel)
) TYPE=MyISAM;

CREATE TABLE tlieferant (
kLieferant int(10) unsigned NOT NULL default '0',
cLiefNr varchar(20) default NULL,
cFirma varchar(50) default NULL,
....
PRIMARY KEY (kLieferant)
) TYPE=MyISAM;

CREATE TABLE tkategorieartikel (
kKategorieArtikel int(10) unsigned NOT NULL default '0',
kArtikel int(10) unsigned NOT NULL,
kKategorie int(10) unsigned NOT NULL,
PRIMARY KEY (kkategorieartikel)
) TYPE=MyISAM;

now i have the following query:

SELECT a.cArtNr, a.cName, la.fEKBrutto, la.fEKNetto, a.fVKBrutto, a.fVKNetto, l.cLiefNr, l.cFirma FROM tArtikel a, tLiefArtikel la, tLieferant l, tKategorieArtikel ka WHERE a.kArtikel='ka.kArtikel' AND a.kArtikel='la.tArtikel_kArtikel' AND la.tLieferant_kLieferant='l.kLieferant' AND ka.kKategorie='x' GROUP BY a.kArtikel ORDER BY a.cName

this one does the following:
i get all products from a category "x" which comes from a random Supplier (in german Lieferant)

What i need is:
all products from a category "x" which comes from the cheapest Supplier.
---> la.fEKNetto should be the minimun and this offer should come from Supplier l.cFirma

i hope you understand my prob:)

hey, i use mysql 4.0x, not 4.1x

greetz and thx
Crysus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top