Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Table Search (I'm trying for ever decreasing circles)

Status
Not open for further replies.

DoubleHelix66

Programmer
Jun 16, 2003
2
AU
I'm using Access (for an asp web site)
I have 5 dropdown lists that relate to 5 tables eg:

Dropdown 1 (CNC)
CNC milling
CNC turning
CNC grinding
(etc)

Dropdown 2 (Tooling Type)
Engraving
Guages
Alloy Wheel Tooling
(etc)

Dropdown 3 (State)
NSW
ACT
NT
VIC
(etc)

The Access database has 5 tables, the first one contains member details, plus unique ID.
The other tables contain products produced, and/or services offered by member companies.
Each member company can have multiple entries in the other tables, and each entry is identified by the same ID as in the member detail table.

Table 1 Example: Membership
MemberID | MemberName | MemberState
--------------------------------------------
101 | BobCo Ltd | NSW
--------------------------------------------
102 | FredCo Ltd | VIC


Table 2 Example: CNC
UniqueID | MemberID | CNCtype
--------------------------------------------
1 | 101 | CNC Milling
--------------------------------------------
2 | 101 | CNC Turning
--------------------------------------------
3 | 102 | CNC Turning
--------------------------------------------
4 | 102 | CNC Grinding


Table 3 Example: Tooling Type
UniqueID | MemberID | ToolingType
--------------------------------------------
1 | 101 | Engraving
--------------------------------------------
2 | 101 | Alloy Wheel Tooling
--------------------------------------------
3 | 102 | Alloy Wheel Tooling
--------------------------------------------
4 | 102 | Guages


I'm trying to build a search page that allows users to pick from one or many of the dropdown menus. Each dropdown has a blank field if it is not included in the search.
So a search by state will return all members in that state, but if the CNC dropdown is set to 'CNC Milling' It will trim down the results, or if the third dropdown is included and set to 'Guages' it will return much less, etc.

This has been made harder by the fact that each table has more columns than those shown, but the search is only of specific columns.

The SQL I have come up with is:
SELECT DISTINCT Membership.MemberID, Membership.MemberName, Membership.MemberState, CNC.MemberID, CNC.CNCtype, Tooling.MemberID, Tooling.ToolingType

FROM Membership, CNC, Tooling

WHERE Membership.MemberID = CNC.MemberID AND Membership.MemberID = Tooling.MemberID AND CNC.CNCtype LIKE 'DropDownA' AND Tooling.ToolingType LIKE 'DropDownB' AND Membership.MemberState LIKE 'DropDownC'

This is soooo wrong that I get hundreds of results from a very small test DB with just 2 or 3 records in it.

Any pointers in the right direction would be much appreciated.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top