473,287 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Query and 1 to many relationship

This must be simple but I can't figure it out. Table 1 1xM to table 2:
Table 1 IDfield
1
2
Table 2 IDfield CriteriaField
1 Criteria value 1
2 Criteria value 1
2 Criteria value 2

For example I need to pull out every IDvalue of table 1 that have both
Criteria value 1 and Criteria value 2 linked to them. In this case IDvalue 2
matches that criteria. In my form I'd like to give the user the option to
choose as many Criteria values for the query as he wants.

How should I configure this query? How should I go about this?
Thanks in advance,
john
Feb 8 '07 #1
2 2730
John,

I believe you're going to have to build a dynamic query definition based on
the following structure:

select *
from Table1
where
exists
(select * from Table2 where Table1.IDField = Table2.IDField and
CriteriaField = 'Criteria Value 1')
and exists
(select * from Table2 where Table1.IDField = Table2.IDField and
CriteriaField = 'Criteria Value 2')

-- Bill

"john" <jo**@test.comwrote in message
news:Wq*********************@casema.nl...
This must be simple but I can't figure it out. Table 1 1xM to table 2:
Table 1 IDfield
1
2
Table 2 IDfield CriteriaField
1 Criteria value 1
2 Criteria value 1
2 Criteria value 2

For example I need to pull out every IDvalue of table 1 that have both
Criteria value 1 and Criteria value 2 linked to them. In this case IDvalue
2 matches that criteria. In my form I'd like to give the user the option
to choose as many Criteria values for the query as he wants.

How should I configure this query? How should I go about this?
Thanks in advance,
john

Feb 9 '07 #2
Thanks. I kinda was afraid of that...
john

"AlterEgo" <al********@dslextreme.comschreef in bericht
news:12*************@corp.supernews.com...
John,

I believe you're going to have to build a dynamic query definition based
on the following structure:

select *
from Table1
where
exists
(select * from Table2 where Table1.IDField = Table2.IDField and
CriteriaField = 'Criteria Value 1')
and exists
(select * from Table2 where Table1.IDField = Table2.IDField and
CriteriaField = 'Criteria Value 2')

-- Bill

"john" <jo**@test.comwrote in message
news:Wq*********************@casema.nl...
>This must be simple but I can't figure it out. Table 1 1xM to table 2:
Table 1 IDfield
1
2
Table 2 IDfield CriteriaField
1 Criteria value 1
2 Criteria value 1
2 Criteria value 2

For example I need to pull out every IDvalue of table 1 that have both
Criteria value 1 and Criteria value 2 linked to them. In this case
IDvalue 2 matches that criteria. In my form I'd like to give the user the
option to choose as many Criteria values for the query as he wants.

How should I configure this query? How should I go about this?
Thanks in advance,
john


Feb 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Simon Withers | last post by:
I have 3 data tables, A, B and C, with many to many relationship tables between A-B and A-C. The data in A and C changes rarely, and the A-C relationship relates all possible combinations of A...
2
by: Todd D. Levy | last post by:
I have a primary table (containing basic contact information) and a number of subsidiary tables (containing various additional information) for employees. Most of the subsidiary tables have a...
4
by: sheree | last post by:
I have 3 tables (amoung a few others) in a small access database. The tables are as follows: == AEReport -------- AEID (PK) RptCatelog GCRCID PatientID EvntDate
3
by: Carmela | last post by:
Hello Readers, I am trying to update data on a form that is based on a query having a many-to-one-to-many relationship. I found this exciting link that seemed to have the solution for me: ...
2
by: Fendi Baba | last post by:
I created a person table with various fields such as Suffix, Salutation, etc, Some of these fields may not be mandatory for example suffix. In the actual table itself, I only have a field for...
4
by: pmacdiddie | last post by:
I have an append query that needs to run every time a line item is added to a subform. The append writes to a table that is the source for a pull down box. Problem is that it takes 5 seconds to...
7
by: J-P-W | last post by:
Hi, in the past I've spent ages writing VB routines to get around this problem, is there a simple way? I have three tables for a membership system: tblMembership - MembershipNumber; Names etc...
6
by: ontherun | last post by:
hi, i am a newbie in access and i created a database which is between client and job. the job fields consists of more than 100 fields. i could not split the fields as the relationship is 1-to1....
5
zachster17
by: zachster17 | last post by:
Hi everyone, First of all, sorry for the massive amount of SQL I am about to type. I have a database that has a "lives" table of insured employees and then another table (that links to the lives...
33
by: mjvm | last post by:
HI, I have a main table (tblStudents) that holds students where the unique field is StudentID; and a related table (tblNotes) on a one-to-many relationship, where the unique field is NotesID, and...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.