complicated query --join

  • Thread starter Thread starter middletree
  • Start date Start date
M

middletree

I'm not used to Access, but can find my way around. Don't know anything
about SP's, etc., and would like to find a query to do this that is just a
plain SQL query, not a SP.

My ASP app (classic ASP) uses an Access 2000 db with 9 tables. 4 are static
and used to populate 4 sets of checkboxes (you can see them at
http://www.middletree.net/shape.asp) The 4 static tables are called People,
Area, Ability, and Gift.

The main table is called Personal, and each individual who fills out the
form will see most of their info, such as name and phone #, stored into the
Personal table, one row per individual. But since I have the possbility of
checking none or many checkboxes in each of the 4 sections of that form, I
have a many-to-many relationship for each one, so I have created the other 4
tables, consisting only of 2 fields: the PK of the Personal table (called
PersonalID) and the PK of each of the other tables. So the table called
PersonalGift has fields called PersonalID and GiftID, for example.

I created an ASP page at http://www.middletree.net/list.asp which lists the
name of all people who have been entered into the system (Fake names for
now, because I'm testing), and the names are links to a page which displays
info about that person, based on what they filled out in the original form.

On the List page, you'll see some dropdowns that I am working on, and that
brings me to my question. I'd like to be able to select something from each
of the 4 different areas, Gift, Ability, People, Area, to narrow down my
search. But I also want to account for the fact that in most cases, not
every dropdown will have something selected.

If this were just one dropdown like this, I could do a join. But I have no
idea how to do with with 4 of them. Can anyone help me? I am looking for
the SQL query code itself, whiuch I can plug into the ASP code.
 
As long as you are going against Access (JET) data, you can concatenate a
wildcard character(aircode)

Select Whatever From YourTable
Where Field1 Like Combo1 & "*" And Field2 Like Combo2 & "*" And Field3 Like
Combo3 & "*" And Field4 Like Combo4 & "*"

That essential says to the query engine to give it the value plus anything
else added to the value. So if you where asking for a name, and entered
Smith, you'd also see Smithson, and Smithfield. But if you entered nothing,
everything would be a match.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top