If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Help with query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-23-12, 06:23
tqz tqz is offline
Registered User
 
Join Date: Apr 2009
Posts: 13
Help with query

Hello all

It has been some time since I have done some sql programming (other than simple select queries) and therfore require some help in writing an sql query. I have tried to simplify it as much as possible with the following example of what I am trying to achieve.

We have two tables, tbl1 and tbl2. Tbl1 contains a list of people and the items they own. Tbl2 contains a list of these items and the groups they belong too. I want to write an sql query that will select all the missing items the person in tbl1 requires in order to have a complete group. If they dont have an item from a group then I dont want that group to appear for that person.

So lets say in monopoly terms, a person owns property on a green street and a brown street, but no property on the yellow street, i want to find the properties he doesnt own on the green and brown street.

Hope the above is clear....

Any guidance or tips on how to do the above would be great!

Thanks in advance!

t.
Reply With Quote
  #2 (permalink)  
Old 06-23-12, 06:44
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 10,496
well might be best to show your tables

there is a wizard in Accessd that will find this for you
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 06-23-12, 08:10
tqz tqz is offline
Registered User
 
Join Date: Apr 2009
Posts: 13
Hi healdem and thanks for your response!

I have resolved this now. I just created two seperate queries 1) all possible items a person could own 2) all the items they do own. I then joined the two queries based on personid and group fields of the queries and then filtered the tables where the items in the two tables did not match.

Works....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On