Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Following are the tables (Feilds wi

Status
Not open for further replies.

tom22london

Programmer
Mar 11, 2003
11
0
0
US
Following are the tables (Feilds with star are foreign keys, with + sysmbols are primary keys)

Borrower(bor_id+, bor_name, bor_maxbooks)

Book_title(bt_id+, bt_name,pub_id*, value)

Book_copy(bc_id+, bt_id*, date acquired)

Loan(bor_id+*, bc_id+*, date_out, date_due, date_back)

Publisher(pub_id+, pub_name, pub_address)

Author(author_id+, author_name)

Authorship(author_id+*, bt_id+*)

Problem is , who (borrower) are currently on loan any title that borrower 'TOM' has on loan.

 
Your question is very hard to understand. Can you give a select statement that doesn't work and why, or a better example?
 
select bor_name,bt_name,date_out,date_due,date_back
from loan a, borrower b,book_title c, book_copy d
where a. bc_id in (select bc_id from loan
where bor_id =(select bor_id from borrower
where bor_name='TOM'))
and a.bor_id=b.bor_id
and a.bc_id =d.bc_id
and d.bt_id = c.bt_id


If you want to exclude Tom

select bor_name,bt_name,date_out,date_due,date_back
from loan a, borrower b,book_title c, book_copy d
where a. bc_id in (select bc_id from loan
where bor_id =(select bor_id from borrower
where bor_name='TOM'))
and a.bor_id=b.bor_id
and a.bc_id =d.bc_id
and d.bt_id = c.bt_id
and b.bor_name<>’TOM’


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top