Restating your question.
You want to select records where the ID and the Principal ID are the same
within one record. Is that correct?
I read your original post, as saying you wanted to select records where the
ID existed in any record (which would be all records except those where ID
is null) or the ID was equal to any Principal ID in any record.
Another interpretation I see is
The ID in a record is equal to the Principal ID in ANY record in the table.
The last should be
SELECT [PMK2005UNIQUE Query].id,
[PMK2005UNIQUE Query].[principal id]
FROM [PMK2005UNIQUE Query]
WHERE [PMK2005UNIQUE Query].id in
(SELECT [Principal ID]
FROM [PMK2005 Unique Query])
There are some other possible interpretations of your request.
--ID in at least one other record and ID = Principal ID in at least one
record in the table (current or other)
--ID in at least one other record and ID = Principal Id in the current
record
--ID in at least one other record and ID = Principal ID in at least one
other record in the table
MorningStarFan said:
Thanks John. That works great if I have an id I want to check. However, I
want to select only those ids where id = id and principal id = id without
entering an id. I did this with vba code and inserted the records into a
new
table. I never got a simple query to do it. Any ideas there?
--
MorningStarFan
John Vinson said:
On Wed, 1 Feb 2006 14:58:14 -0800, "MorningStarFan"
Hi - I need to write a query which will get all rows where an id is in
either
of two different columns in any row in the table. I hope this makes
sense.
Here is what I wrote. I get an error when I try this...
SELECT [PMK2005UNIQUE Query].id, [PMK2005UNIQUE Query].[principal id]
FROM [PMK2005UNIQUE Query] where [PMK2005UNIQUE Query].id in ((select
[PMK2005UNIQUE Query].id from [PMK2005UNIQUE Query]) AND (select
[PMK2005UNIQUE Query].[principal id] from [PMK2005UNIQUE Query]))
This makes no sense. You're apparently trying to select those records
where the ID is in the same query. You're using [PMK2005UNIQUE Query]
in both the main query and both subqueries. Nowhere does this query
prompt for an ID.
I'm GUESSING that what you want is
SELECT <whatever>
FROM [PMK2005UNIQUE Query]
WHERE [ID] = [Enter ID:]
OR [Principal ID] = [Enter ID:]
This will prompt you for an ID and return whichever fields you choose
if that ID occurs in either field (matching what you say in the text,
though not the same as your subject line).
John W. Vinson[MVP]