A Microsoft Office (Excel, Word) forum. OfficeFrustration

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   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query to return a subset of a set



 
 
Thread Tools Display Modes
  #1  
Old May 10th, 2008, 01:41 AM posted to microsoft.public.access.queries
David Wetmore
external usenet poster
 
Posts: 21
Default Query to return a subset of a set

I have an M2M relation with a link table (tblTagLinks) containing parent keys (PKey) and child keys (CKey).
I want to return the smallest set of PKey values which have links to two different CKey values.

In other words, how do I combine

SELECT tblTagLinks.PKey
FROM tblTagLinks
WHERE tblTagLinks.CKey = 88

and

SELECT tblTagLinks.Pkey
FROM tblTakLinks
WHERE tblTagLinks.CKey = 50

to get only those PKey values where the result is a subset of CKey 88
containing only those records which also have a link containing CKey = 50?

For example, if one set from tblTagLinks contains

12, 88
14, 88
19, 88

and another set contains

11, 50
12, 50
18, 50

I want an SQL statement which will select only 12 for the PKey

I've tried AND and OR combinations, but all I get is either the empty set or a union.
  #2  
Old May 10th, 2008, 06:56 PM posted to microsoft.public.access.queries
David Wetmore
external usenet poster
 
Posts: 21
Default Query to return a subset of a set

Please ignore this thread. I havn't thought the problem through yet.
 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.