PC Review


Reply
Thread Tools Rate Thread

List items with no match

 
 
Janelle
Guest
Posts: n/a
 
      10th Dec 2003
I have a table with a list of brands.
I have another table with a list of categories.
I have a third table which creates a many-to-many
relationship between the two.

Now, I know how to make a query that will show all the
categories associated with Brand 1. But how do I get a
list of all the categories that are NOT associated with
Brand 1?

Everything I've tried so far gets fouled up by matches
with other brands.
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      10th Dec 2003
"Janelle" <(E-Mail Removed)> wrote in message
news:087801c3bf43$201a3b90$(E-Mail Removed)
> I have a table with a list of brands.
> I have another table with a list of categories.
> I have a third table which creates a many-to-many
> relationship between the two.
>
> Now, I know how to make a query that will show all the
> categories associated with Brand 1. But how do I get a
> list of all the categories that are NOT associated with
> Brand 1?
>
> Everything I've tried so far gets fouled up by matches
> with other brands.


Suppose that your tables are named Brands, Categories, and
BrandsCategories (the linking table). The first thing you need is a
query that returns all the Categories a query that selects all
Categories from BrandsCategories where Brand = 1:

SELECT
BrandsCategories.BrandID
FROM
BrandsCategories
WHERE BrandsCategories.BrandID=1

Now you need to create a "find unmatched" query that joins this query
with Categories and returns all Categories records that are unmatched.
You could save the above query as a storder query and then use the Find
Unmatched Query Wizard to build the final query, or you could take the
above SQL statement and use it as a subquery in a single query:

SELECT
Categories.*
FROM
Categories
LEFT JOIN
(SELECT BrandsCategories.BrandID
FROM BrandsCategories
WHERE BrandsCategories.BrandID=1) As T
ON Brands.BrandID = T.BrandID
WHERE T.BrandID Is Null

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
 
 
 
domains
Guest
Posts: n/a
 
      10th Dec 2003
Just use the 'Find Unmatched Query Wizard'.

"Janelle" <(E-Mail Removed)> wrote in message
news:087801c3bf43$201a3b90$(E-Mail Removed)...
> I have a table with a list of brands.
> I have another table with a list of categories.
> I have a third table which creates a many-to-many
> relationship between the two.
>
> Now, I know how to make a query that will show all the
> categories associated with Brand 1. But how do I get a
> list of all the categories that are NOT associated with
> Brand 1?
>
> Everything I've tried so far gets fouled up by matches
> with other brands.



 
Reply With Quote
 
Janelle
Guest
Posts: n/a
 
      10th Dec 2003
Perfect! Thanks! I didn't know there was one...

>-----Original Message-----
>Just use the 'Find Unmatched Query Wizard'.
>
>"Janelle" <(E-Mail Removed)> wrote in

message
>news:087801c3bf43$201a3b90$(E-Mail Removed)...
>> I have a table with a list of brands.
>> I have another table with a list of categories.
>> I have a third table which creates a many-to-many
>> relationship between the two.
>>
>> Now, I know how to make a query that will show all the
>> categories associated with Brand 1. But how do I get a
>> list of all the categories that are NOT associated with
>> Brand 1?
>>
>> Everything I've tried so far gets fouled up by matches
>> with other brands.

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lookup Formula: Return 1st match, then 2nd match, then 3rd match Scott Microsoft Excel Misc 4 11th Dec 2009 06:50 AM
Compare List A to List B, Return List B Items Not in List A zwestbrook Microsoft Excel Programming 4 18th Sep 2008 10:32 PM
Delete duplicate items in sent items or how to sort by how many items in conversation view dangmoss Microsoft Outlook Discussion 2 2nd Feb 2006 03:59 AM
searching a list box for a filename match...and highlighting the match suee Microsoft Excel Programming 1 13th Apr 2004 02:56 AM
IF(ISERROR(MATCH - need value where match was found Ed Microsoft Excel Programming 2 12th Nov 2003 10:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:45 AM.