Jump to content

Querying to find amount of exact same records and...


masscrazy

Recommended Posts

Hi,

 

My database currently consists of Users, Tracks and Ratings. Currently there are two users who have rated about 4 items. This is how it looks.

 

+------+-------+--------+

| user | track | rating |

+------+-------+--------+

| 9999 |    1 |      4 |

| 9989 |    1 |      1 |

| 9989 |    2 |      1 |

| 9989 |    3 |      5 |

| 9999 |    2 |      1 |

| 9999 |    3 |      1 |

| 9999 |    4 |      5 |

| 9989 |    4 |      5 |

+------+-------+--------+

8 rows in set (0.00 sec)

 

 

So im trying to figure out if 2 given users have rated the same items or not using SQL. Anyone that can help me out? I am also trying to find out how i would work out WHICH items the two given users rated.

 

 

OK So i have this query how would i left join it, bearing in mind all this data is on one table.

 

SELECT * FROM userratings WHERE (user = 9999 OR 9989) AND track = 1 AND rating = 1;

You want one query for each user, and left join them....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.