ssteinke
for what it's worth
- Local time
- Today, 04:05
- Joined
- Aug 2, 2003
- Messages
- 195
I have a table, named tblRecords, and a joined table, named tblUserRecords. The tables are one-to-many joined by RecordID.
In tblRecords, I have a field named UserID to show who entered the record.
In tblUserRecords, I also have a field named UserID for user(s) who have access to the record.
I want a query to show two seperate records if a user has both entered the record and received the record (i.e. tblRecords.UserID and tblUserRecords.UserID are the same).
An example of what I am not looking for,
This gives me
4 Bob Randy
4 Bob Bob
4 Bob Gregg
7 Gregg Bob
9 Tom Bob
This is what I want
4 Bob Entered
4 Bob Received
7 Bob Received
9 Bob Received
Does this require a subselect or subquery?
In tblRecords, I have a field named UserID to show who entered the record.
In tblUserRecords, I also have a field named UserID for user(s) who have access to the record.
I want a query to show two seperate records if a user has both entered the record and received the record (i.e. tblRecords.UserID and tblUserRecords.UserID are the same).
An example of what I am not looking for,
Code:
SELECT tblRecords.RecordID, tblRecords.UserID, tblUserRecords.UserID
FROM tblRecords
LEFT JOIN tblUserRecords ON tblRecords.RecordID = tblUserRecords.RecordID
WHERE tblRecords.UserID='Bob' OR tblUserRecords.UserID='Bob'
This gives me
4 Bob Randy
4 Bob Bob
4 Bob Gregg
7 Gregg Bob
9 Tom Bob
This is what I want
4 Bob Entered
4 Bob Received
7 Bob Received
9 Bob Received
Does this require a subselect or subquery?