October 30, 2009 at 2:58 am
hello
I have a task to find the titles of books that are only on sale from branch number 1 of 4 total branches.
List the book titles of books which are ONLY available (on hand) at Branch Number 1. Order the list alphabetically by book title.
But the output from my query involves titles from books that are on sale at branch bumber 1 and are on sale at others also?
My query(which does not work correctly):
select title, branch_num, B.book_code
from book B, inventory I
where B.book_code = I.book_code and branch_num not in(2,3,4)
order by title asc;
October 30, 2009 at 3:01 am
ok if you want it to be from branch 1, then change it to say branch_num = 1
--------------------------------------------------------------------------------------
[highlight]Recommended Articles on How to help us help you and[/highlight]
[highlight]solve commonly asked questions[/highlight]
Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden[/url]
Managing Transaction Logs by Gail Shaw[/url]
How to post Performance problems by Gail Shaw[/url]
Help, my database is corrupt. Now what? by Gail Shaw[/url]
October 30, 2009 at 3:15 am
Try this
Select * from inventory B1Inventory
left join inventory OtherBranchInventory
on OtherBranchInventory.Book_code = B1Inventory.Book_Code
and OtherBranchInventory.Branch_num <> 1
where B1Inventory.Branch_num = 1
and OtherBranchInventory.Branch_num is null
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply