Re: SQL Query Problem

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Tue, 18 May 2004 08:18:20 -0400
Message-ID: <z7OdnfTdT_TEYjTdRVn-iQ_at_comcast.com>


"bnp" <bhaviknpatel_at_yahoo.com> wrote in message news:7d72bcc.0405162046.66bc2460_at_posting.google.com...
| Hi All,
|
| I am a trainee programmer working SQL
| I was given a set of queries to solve for following 3 tables
|
| TBL_Authors(table 1)
| author_id(primary key) author_name author_address
|
| TBL_Books (table 2)
| book_id(primary key) book_name book_synopsys book_pub_date
|
| TBL_Author_Book_Link (table 3)
| author_id(not null) book_id (not null)
|
| Following are the constraints to solve the query
| - GROUP BY is not allowed.
| - An author may have written multiple books
| - A book may be written by multiple authors.
|
| The query is as below:
| - Find all authors who have not written specific book(i.e. a book_id
| OR book_name) or are not associated with specified book.
|
| I tried it for long time, but was not able to solve it.
|
| Please help me to solve this problem.
|
| Thanks & Regards,
|
| Bhavik

in general, approach the problem by breaking down the logic that needs to be applied into smaller steps; think of how you would do it manually -- that is, if all you had to work with were 3 hard-copy lists of authors, books, and the book-link list, and then determine how SQL can be used to do similar processing

for this problem, the 'have not written' makes it a bit more difficult than otherwise

try solving the problem first with the slightly different criteria 'authors who have written...'

then, see how you might revise that solution to use outer joins or the minus operator to get the 'have not written...' solution

also... assuming your instructor has presented things logically and progressively, go back and review previous exercises and examples that demonstrate the concepts necessary to solve this one

  • mcs
Received on Tue May 18 2004 - 14:18:20 CEST

Original text of this message