Last active
August 31, 2022 12:54
-
-
Save saqibmehmoodgit/2c5337ff4d13499dfb6af71f6d695c20 to your computer and use it in GitHub Desktop.
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
book table | author table | BOOK_AUTHORS | |
id name | id name | book_id author_id | |
1 dubai visit | 1 abc | 1 1 | |
2 pak visit | 2 def | 1 2 | |
| 2 2 | |
SELECT ba.book_Id FROM BOOK_AUTHORS ba | |
JOIN Book b ON ba.book_Id = b.id | |
JOIN BOOK_AUTHORS ba2 ON b.id = ba2.book_Id | |
WHERE ba2.authors_Id = 2 | |
GROUP BY ba.book_Id | |
HAVING count(ba.authors_Id) = 1 | |
Explanation ::: Till line number 09 , this is my paper work | |
b.bid b.name ba.BOOK_ID ba.AUTHORS_ID ba2.BOOK_ID ba2.AUTHORS_ID | |
1 Dubai Visit 1 1 1 2 | |
1 Dubai Visit 1 2 1 2 | |
2 China Visit 2 2 2 2 | |
my question is that how line 10 and 11 will work . final answer is 2 . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment