MySQL Query for Library Database -


i have database project struggling 3 queries. please help?

i have following tables:

member(memberno, name, age) book(isbn, title, author, publisher, year, category) borrowed(memberno, isbn, date) 

and have answer each of following questions formulating single sql query (i.e. not use views):

1) each category, find names of members have borrowed more 5 books in category.

2) find prolific author in library, i.e., author has authored books.

3) find names of members have borrowed same book more once.

thanks lot

so far have tried following:

1) query:

select member.name    member   member.memberno in(select borrowed.memberno                              borrowed                             group                                memberno                            having count(memberno)>5) 

result: seems return correct result, haven’t figured out how add ‘category’ per question.

2) query:

select author       , count(*) 'books written'    book   group      author  having count(isbn)>6 

result: returns correct result, because have specified more 6 – , because know have author has written 7 books, therefore specifying ‘more 6’ – not sure how write query determine ‘most books written’ itself

3) query:

select member.name    member   member.memberno in (select borrowed.memberno                               borrowed                              borrowed.isbn in(                                    select count(borrowed.isbn) 'con'                                       borrowed                                      'con' >1)) 

result: query returns rows member names, not correct – of members have borrowed more 1 book (but not same book more once) other members have not borrowed books more once – query not correct.

here's clue 1....

select b.something      , c.something_else     join b     on b.x = a.x   join c     on c.y = a.y  group      b.m      , c.n having count(*) >= 5; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -