Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Query question, Need to write a query that returns only the students that have read all books by an author.
I need to write a query that returns only the students that have read
all books by an author. I have these tables set up so far....
create table Books (
BookTitle varchar2(20) PRIMARY KEY, author varchar2(20)
create table BookCamp (
MemberName varchar2(20), BookTitle varchar2(20), CONSTRAINT fk_BookTitle FOREIGN KEY (BookTitle) REFERENCES Books(BookTitle)
insert into Books values ('Psycho', 'Brian'); insert into Books values ('Happy Rotter', 'Rocksteady'); insert into Books values ('Goblet', 'J.K Rowling'); insert into Books values ('Prisoner', 'J.K Rowling'); insert into BookCamp values ('Bob', 'Psycho'); insert into BookCamp values ('Chuck', 'Goblet'); insert into BookCamp values ('Chuck', 'Prisoner'); insert into BookCamp values ('Mike', 'Psycho'); insert into BookCamp values ('Mike', 'Goblet');insert into BookCamp values ('Mike', 'Prisoner'); insert into BookCamp values ('Mary', 'Goblet');
So basically, if I inputted "J.K Rowling" the names "Chuck" and "Mike" should come up. If the author is "Brian" then the names "Bob" and "Mike" should come up. I've tried several things like... select membername from BookCamp where BookTitle in(select BookTitle from Books where (author = 'J.K Rowling')); but this obviously isn't quite there....Any Help? Received on Fri Jun 08 2007 - 16:56:07 CDT