Created
July 7, 2011 02:00
-
-
Save RobinStamer/1068764 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
| mysql> SELECT AVG(rating), songs.song_id FROM songs LEFT JOIN ratings USING (song_id) GROUP BY songs.song_id; | |
| +-------------+---------+ | |
| | AVG(rating) | song_id | | |
| +-------------+---------+ | |
| | NULL | 1 | | |
| | 2.5000 | 2 | | |
| | NULL | 3 | | |
| +-------------+---------+ | |
| 3 rows in set (0.02 sec) | |
| mysql> SELECT * FROM songs; | |
| +---------+ | |
| | song_id | | |
| +---------+ | |
| | 1 | | |
| | 2 | | |
| | 3 | | |
| +---------+ | |
| 3 rows in set (0.00 sec) | |
| mysql> SELECT * FROM ratings; | |
| +---------+--------+ | |
| | song_id | rating | | |
| +---------+--------+ | |
| | 2 | 4 | | |
| | 2 | 2 | | |
| | 2 | 3 | | |
| | 2 | 1 | | |
| +---------+--------+ | |
| 4 rows in set (0.00 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment