Skip to content

Instantly share code, notes, and snippets.

Created November 25, 2013 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7642550 to your computer and use it in GitHub Desktop.
Save anonymous/7642550 to your computer and use it in GitHub Desktop.
Lessons table
------------
|id |name |
-----------
|1 |test |
|2 |hello |
|3 |world |
------------
Sessions table
------------
|id |name |
------------
|1 |dogs |
|2 |cats |
|3 |birds |
------------
Sessions/lessons junction table
----------------------------
|id |session_id |lesson_id |
----------------------------
|1 |1 |1 |
|2 |1 |2 |
|3 |2 |1 |
----------------------------
I want to get lessons associated with session 2
-------------------------
|lesson id |lesson name |
-------------------------
|1 |test |
-------------------------
I also want to get lessons that are NOT associated with session 2
-------------------------
|lesson id |lesson name |
-------------------------
|2 |hello |
|3 |world |
-------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment