By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,124 Members | 2,208 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,124 IT Pros & Developers. It's quick & easy.

selection criteria spread on multiple rows

P: n/a
Hi,

I'm having the following problem. I have a table that contains
information about books people read, i.e. each row has two columns,
people id and book id.
I need to do the following query: retrieve the list of all people that
read ALL the books in a given list, e.g. all the people that read book
X and book Y and book Z.
Tu further complicate the situation, an extended query also include an
exclusion crieteria, i.e. a list of books that the user should not
have read.

I really have no clue on how to approach this.
Any help will be much appricated.

Abe.
Dec 16 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You will need to use subqueries to achieve this.

Here's a starting point:
Subquery basics
at:
http://allenbrowne.com/subquery-01.html

It may be possible to create a query that groups by the person and book,
where the book is IN a list of books, and take the count to see if you got
all 3. But you need to be sure you avoid the case where someone read a book
twice.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<ab*************@gmail.comwrote in message
news:47**********************************@s19g2000 prg.googlegroups.com...
Hi,

I'm having the following problem. I have a table that contains
information about books people read, i.e. each row has two columns,
people id and book id.
I need to do the following query: retrieve the list of all people that
read ALL the books in a given list, e.g. all the people that read book
X and book Y and book Z.
Tu further complicate the situation, an extended query also include an
exclusion crieteria, i.e. a list of books that the user should not
have read.

I really have no clue on how to approach this.
Any help will be much appricated.

Abe.
Dec 16 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.