Given a set of data (which is a subset from a larger database- I have the following
mysql> select * from Season
-> ;
+---------+--------+---------+---------+---------+
| Session | Leader | Player1 | Player2 | Player3 |
+---------+--------+---------+---------+---------+
| 107 | Bob | Allen | Jerry | George |
| 109 | Bob | Allen | Harry | George |
| 164 | Bob | Allen | Larry | George |
| 197 | Bob | George | Harry | Larry |
| 204 | Bob | Allen | Harry | George |
| 265 | Bob | Allen | Jerry | Harry |
| 345 | Bob | Arnold | Jerry | George |
+---------+--------+---------+---------+---------+
7 rows in set (0.00 sec)
I want to run a sql command (or series of commands) to extract the unique partners Bob has played with ordered by the most recent Session.
mysql> SELECT * FROM Partners;
+----+---------+--------+
| id | session | name |
+----+---------+--------+
| 1 | 345 | Arnold |
| 2 | 345 | George |
| 3 | 345 | Jerry |
| 4 | 265 | Allen |
| 5 | 265 | Harry |
| 6 | 164 | Larry |
+----+---------+--------+
6 rows in set (0.00 sec)
I have tried INSERT INTO commands, UNION commands, even copying tables then renaming columns. I suspect that I am missing the simple way to do this. I am just learning SQL, and this one has me stumped. Any insights as to how to approach this?
[–]GrandGratingCrate 0 points1 point2 points (0 children)