-5

i found this error when I enter this command

SELECT *
FROM  Borrowed_Book , User
WHERE User.UserId=Borrowed_Book.UserId  IN (
    SELECT *
    FROM Book , Book_version_info
    WHERE 
        Book_version_info.PublisherID = 1 AND 
        Book.ISBN= Book_version_info.Book_ISBN
);

i cannot find what's the issue here and why i get this error I search on the internet but I don’t find the reason

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
samxx123
  • 13
  • 4
  • What do you believe `WHERE a = b IN ( ... )` means, and why do you believe that? Perhaps if you took another look at how the `IN` clause works, it might be illuminating, e.g. web search for [`sql in subquery`](https://www.google.com/search?q=sql+in+subquery). – Andreas Nov 28 '20 at 21:13
  • What you try to achieve by your query? – Slava Rozhnev Nov 28 '20 at 21:14
  • Please do your homework on your own or use the search function to find a suitable answer here ;-) – Markus Safar Nov 28 '20 at 21:15
  • "i found this error when I enter this command", What error??? – Yunfei Chen Nov 29 '20 at 00:50

1 Answers1

0

First of all you should match your columns in the IN function:

WHERE User.UserId=Borrowed_Book.UserId  IN (
    SELECT *
    FROM Book , Book_version_info
    WHERE 
        Book_version_info.PublisherID = 1 AND 
        Book.ISBN= Book_version_info.Book_ISBN
);

SQL does not know what to do with that the columns should be same so try instead:

WHERE User.UserId=Borrowed_Book.UserId  AND User.UserId IN (
    SELECT User.UserId
    FROM Book , Book_version_info, User
    WHERE 
        Book_version_info.PublisherID = 1 AND 
        Book.ISBN= Book_version_info.Book_ISBN
);
Yunfei Chen
  • 630
  • 1
  • 8
  • 20