[thelist] (SQL) Query with Multi FK's to the same lookup

Tab Alleman Tab.Alleman at MetroGuide.com
Fri May 14 14:06:45 CDT 2004


Suppose you've got a table with some products that can be rated for
various qualities, and you've got a lookup table that associates a
description with the rating:

Products Table:
Prod_ID	OverallRating	FeaturesRating	ValueRating	
1		3			1			5
2		4			4			4
3		4			2			5
...

Rating Table:
Rating	Description
1		Poor
2		Fair
3		Average
4		Good
5		Excellent


I'm trying to think of a way to return a recordset of each Prod_ID with
the Description associated with each rating:

Prod_ID	OverallRating	FeaturesRating	ValueRating	
1		Average		Poor			Excellent
2		Good			Good			Good
3		Good			Fair
Excellent
...



 ...and the only way I can think to do it is to JOIN the two tables once
for each rating column, but that seems awfully wasteful.  My anal side
is telling me there ought to be a way to do it with a single JOIN.  Is
there?


More information about the thelist mailing list