Created
August 14, 2015 13:54
-
-
Save FernandoBasso/c6631edbd6afc633e2cd to your computer and use it in GitHub Desktop.
Three-table sql join
This file contains 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
-- I have the tables `category`, `subscription` and `document`. Document | |
-- references subscription, and subscription references category. I am trying to | |
-- get the category name based on a documents PK. I am doing something like this: | |
SELECT category_name FROM categorias | |
INNER JOIN subscription ON category_fk = category_pk | |
INNER JOIN documents ON subscription_fk = document_pk | |
AND document_pk = 14; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment