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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using values in a table for criteria

Status
Not open for further replies.

Board2Death

Technical User
Apr 27, 2005
88
US
I have a table that has the employee ID as a field. How do use all the employee ID's as critreia? For example the criteria would be something like "ID001" or "ID002" or "ID003" or ...

I do not want to type all 50 ID's for each query that I have to write. Can the query just use the values form the ID field in the table somehow?
 


Hi,
Code:
...
From MyTable1
Where EmployeeID in (Select EmployeeID From MyTable2)


Skip,

[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue]
 
Not quite sure I follow this. Why do you have two tables?
 

Why would you use the same table?

Skip,

[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue]
 
FROM MyTable1 INNER JOIN MyTable2 ON MyTable1.EmployeeID = MyTable2.EmployeeID

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I think that I may have either not posted a clear question...or maybe I just don't understand the replies. Let me try to explain better what I am doing.

I have a table (tblQualityStaff) with employeeID as a field. I guess this table qualifies as a lookup table since the only fields in the table are employeeName and employeeID.

I want to write a query that returns some data from a table called tblLots. tblLots contains a field called addedBy (which contains the employeeID of the person who created the record in tblLots).

I want to create a query the returns results from tblLots where the addedBy field is equal to one of the employeeID found in the tblQualityStaff.

If I am in over my head, I appologize for taking up your guys time. I do truely appreciate your efforts to help.

 
SELECT *
FROM tblLots INNER JOIN tblQualityStaff ON tblLots.addedBy = tblQualityStaff.employeeID;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top