Help with WHERE in SQL statement

Posted on 2011-10-04
Last Modified: 2012-05-12
I would like to evalute after AS Store a Where statement that says only include from tblDesignatedEmployee.EmployeeTypeID=1
I continue this pattern at AS District a Where statement that says only include from tblDesignatedEmployee.EmplooyeeTypeID=2
I continue this pattern at AS Support Where statement that says only include from tblDesignatedEmployee.EmployeeTypeID=3
I continue this pattern at AS StoreMgr Where statement that says only include from tblDesignatedEmployee.EmployeeTypeID=4

In other words I want to include only District Managers if the tblDesignatedEmployee.EmployeeTypeID = 1
Include only Support in the tblDesignatedEmployee.EmployeeTypeID=2
Include only StoreMgr in the tblDesignatedEmployee.EmployeeTypeID=3
Include only AsstStorMgr in the tblDesignatedEmployee.EmployeeTypeID=4

SELECT tblStore.StoreNumberID, "Store #" & " " & tblStore.StoreNumber & " " & tblStore.StoreName & " " & tblStates.State AS Store, tblEmployee.EmployeeFirstName & " " & tblEmployee.EmployeeLastName AS District, tblEmployee_1.EmployeeFirstName & " " & tblEmployee_1.EmployeeLastName AS Support, tblEmployee_2.EmployeeFirstName & " " & tblEmployee_2.EmployeeLastName AS StoreMgr, tblEmployee_3.EmployeeFirstName & " " & tblEmployee_3.EmployeeLastName AS AsstStoreMgr
FROM tblStates INNER JOIN (tblStore INNER JOIN (tblEmployee AS tblEmployee_3 INNER JOIN (tblEmployee AS tblEmployee_2 INNER JOIN (tblEmployee AS tblEmployee_1 INNER JOIN (tblEmployee INNER JOIN tblDesignatedEmployee ON tblEmployee.EmployeeID = tblDesignatedEmployee.EmployeeID) ON tblEmployee_1.EmployeeID = tblDesignatedEmployee.EmployeeID) ON tblEmployee_2.EmployeeID = tblDesignatedEmployee.EmployeeID) ON tblEmployee_3.EmployeeID = tblDesignatedEmployee.EmployeeID) ON tblStore.StoreNumberID = tblDesignatedEmployee.StoreID) ON tblStates.StateID = tblStore.StateID
ORDER BY tblStore.StoreNumber;
Question by:Frank Freese
    LVL 12

    Expert Comment

    In your query, you add the fields where you want to set your criteria. You dont have to Show them, the uncheck the Show checkbox.

    Hope this helps,
    LVL 16

    Accepted Solution

    You'll need to create separate queries for each of your WHERE conditions and then join them together on some common ID.

    Author Closing Comment

    by:Frank Freese
    thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now