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

Tab Alleman Tab.Alleman at MetroGuide.com
Wed May 19 10:02:41 CDT 2004


Hassan Schroeder wrote:
> Tab Alleman wrote:
>> 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:
> 
> Frankly, if this were MySQL, at least, I'd redefine all the rating
> columns to ENUM('Poor','Fair','Average','Good','Excellent'); you'd
> use your existing numeric insert/update statements but would get a
> string back on selects...

Hard-coding like this isn't desirable in this case because if I ever
need to change "Excellent" to "Superior", for instance, I'd have to
change it in all my SQL queries instead of in the lookup table.


More information about the thelist mailing list