and that should work...Tables like... create table items ( itemid int(11) default 0 not null, other_data text, primary key (itemid); ); create table ratings ( itemid int(11) default 0 not null, ratingtype varchar(32) default '' not null, rating int(11) default 0 not null, primary key (itemid,ratingtype), key (itemid,ratingtype,rating) }; SELECT * FROM items AS I, ratings AS R WHERE R.itemid = I.itemid AND R.ratingtype = 'usability' AND R.rating >= 8;
I just used int for rating for simplicity, you'd probably use a decimal...
Or are there multiple ratings for on item in the same ratingtype? like an entry for each person
who rarted it? If that is the case I would suggest just storing the average if you
can, or having a table of averages and a table of all entries.
but maybe I misunderstand.
- Ant
In reply to Re: (OT) Improving a SQL JOIN statement
by suaveant
in thread (OT) Improving a SQL JOIN statement
by Masem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |