How to use AND in a one to many table query?

Giganews Newsgroups
Subject: How to use AND in a one to many table query?
Posted by:  Patrick Finucane (patrickfinucane…@gmail.com)
Date: Fri, 13 Dec 2019

I have 2 tables; Contact and Category,  A contact is a single record.  A co=
ntact can have 1 or many categories contained in the Category table.

For example, lets say i have contact John.  John has a category record Phar=
macy and another category record for Electric. =20

What could I use as a select statement to get both categories for Jphn.  Fo=
r example, I have a multi-select listbox where I select Pharmacy and Electr=
ic to filter my category table list.  I want to select/filter all contacts =
that have both Pharmacy and Electric as categories.  Not just 1 category. =
=20

I can't use OR.  That will pull up contacts that have either one of the cho=
ices but maybe not both.  I want contacts that have both categories.

If I use AND I don't get any records since the Category table has one categ=
ory/contact per record.  Category =3D Electic and category =3D Pharmacy won=
't work.  That assumes 2 pr more categories per record

Do you see a way where I can select all records that have both categories i=
n the category table?

Replies