473,406 Members | 2,281 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,406 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 2732
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.