Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dlmagers10
Starting Member
48 Posts |
Posted - 2010-10-22 : 10:27:39
|
| Ok trying to find the book title for each book written by author num 18. Trying to use the IN operator.BOOK TABLE INCLUDES: BOOK_CODE, TITLE, PUBLISHER_CODE, TYPE, PRICE, PAPERBACKAUTHOR TABLE INCLUDES: AUTHOR_NUM, AUTHOR_LAST, AUTHOR_FIRSTWROTE TABLE INCLUDES: BOOK_CODE, AUTHOR_NUMINVENTORY TABLE INCLUDED: BOOK_CODE, BRANCH_NUM, ON_HANDTHIS IS WHAT I HAVE THUS FAR:SELECT TITLEFROM BOOK BWHERE B.AUTHOR_NUM IN(SELECT AUTHOR_NUMFROM AUTHORWHERE AUTHOR_NUM = '18');Hey just someone would just please help to understand. I do not want the answer. Just a littl help answering this question. I kinda need the answer this in an IN operator then I need to turn around and answer in an EXISTS operator in my query. |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2010-10-22 : 11:08:58
|
| Maybe this will help... http://sqlinthewild.co.za/index.php/2009/08/17/exists-vs-in/Since the table B doesn't have the AuthorNum column, your IN needs to compare Book code (in the books table) against book code in the Wrote table, and the filter for author num can be done against that table. (so the IN subquery needs to be against only the Wrote table)--Gail ShawSQL Server MVP |
 |
|
|
|
|
|