leeclements
04-11-2007, 06:35 PM
Hey,
I have two tables (well, more but these two are the only ones i'm querying)
book
id | title | author | publisher | edition| ISBN (id being the primary key)
readinglist
bookID| moduleID (the 2 making a primary key)
what I would like to do is count how many times each book ID is present and return any that appear more than once (most popular 1st)and also display the book title as well, like:
bookID | title | count
At the moment I have:
SELECT bookid, count(bookid) FROM readinglist
GROUP BY bookid
HAVING COUNT(*) > 1;
which returns the book id and number of times it appears I would like to join onto it something like:
SELECT title
FROM textbook;
to get the title up. However I'm not sure how to do this. Anyone got any pointers?
(by the way I'm using oracle)
thanks in advance
Lee
I have two tables (well, more but these two are the only ones i'm querying)
book
id | title | author | publisher | edition| ISBN (id being the primary key)
readinglist
bookID| moduleID (the 2 making a primary key)
what I would like to do is count how many times each book ID is present and return any that appear more than once (most popular 1st)and also display the book title as well, like:
bookID | title | count
At the moment I have:
SELECT bookid, count(bookid) FROM readinglist
GROUP BY bookid
HAVING COUNT(*) > 1;
which returns the book id and number of times it appears I would like to join onto it something like:
SELECT title
FROM textbook;
to get the title up. However I'm not sure how to do this. Anyone got any pointers?
(by the way I'm using oracle)
thanks in advance
Lee