Created
June 16, 2010 01:52
-
-
Save latompa/440013 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Videos | |
+------+------------------+ | |
| id | uploaded_by_user | | |
+------+------------------+ | |
| 1 | tom | | |
| 2 | mark | | |
| 3 | tom | | |
| 4 | mark | | |
| 5 | tom | | |
| 6 | john | | |
+------+------------------+ | |
Video_ratings: | |
+----------+--------+---------------+ | |
| video_id | rating | rated_by_user | | |
+----------+--------+---------------+ | |
| 1 | 5 | tom | | |
| 1 | 4 | mark | | |
| 5 | 2 | mark | | |
+----------+--------+---------------+ | |
The simplest query we could come up with was: | |
select id from videos | |
where not exists | |
(select video_id as id from video_ratings | |
where videos.id=video_ratings.video_id | |
and video_ratings.rated_by_user='mark' | |
) | |
and uploaded_by_user != 'mark' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment