masscrazy Posted January 27, 2008 Share Posted January 27, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/87989-querying-to-find-amount-of-exact-same-records-and/ Share on other sites More sharing options...
fenway Posted January 27, 2008 Share Posted January 27, 2008 You could join with user & track if both were known.... Quote Link to comment https://forums.phpfreaks.com/topic/87989-querying-to-find-amount-of-exact-same-records-and/#findComment-450211 Share on other sites More sharing options...
masscrazy Posted January 27, 2008 Author Share Posted January 27, 2008 You mean having a where and AND clause? But what if you didnt know? Quote Link to comment https://forums.phpfreaks.com/topic/87989-querying-to-find-amount-of-exact-same-records-and/#findComment-450364 Share on other sites More sharing options...
fenway Posted January 27, 2008 Share Posted January 27, 2008 Then you'd have to to pull all the track for each user in seperate select statements, and left join them in mysql. Quote Link to comment https://forums.phpfreaks.com/topic/87989-querying-to-find-amount-of-exact-same-records-and/#findComment-450495 Share on other sites More sharing options...
masscrazy Posted January 27, 2008 Author Share Posted January 27, 2008 BTW, where i've used item in my first post it supposed to be track. Quote Link to comment https://forums.phpfreaks.com/topic/87989-querying-to-find-amount-of-exact-same-records-and/#findComment-450576 Share on other sites More sharing options...
masscrazy Posted January 28, 2008 Author Share Posted January 28, 2008 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; Quote Link to comment https://forums.phpfreaks.com/topic/87989-querying-to-find-amount-of-exact-same-records-and/#findComment-450873 Share on other sites More sharing options...
fenway Posted January 28, 2008 Share Posted January 28, 2008 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.... Quote Link to comment https://forums.phpfreaks.com/topic/87989-querying-to-find-amount-of-exact-same-records-and/#findComment-451409 Share on other sites More sharing options...
masscrazy Posted January 29, 2008 Author Share Posted January 29, 2008 Is this a one man forum? Cos the one person that is replying is no help. Next forum... Quote Link to comment https://forums.phpfreaks.com/topic/87989-querying-to-find-amount-of-exact-same-records-and/#findComment-451978 Share on other sites More sharing options...
fenway Posted January 29, 2008 Share Posted January 29, 2008 Is this a one man forum? Cos the one person that is replying is no help. Next forum... If you're referring to me, then I will stop "helping" you forever. Good luck (and learn how to fish). Quote Link to comment https://forums.phpfreaks.com/topic/87989-querying-to-find-amount-of-exact-same-records-and/#findComment-452406 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.