B
billmuir
My table has four fields, I want the records were the first 3 fields
match and the fourth field does not.
Thks
match and the fourth field does not.
Thks
My table has four fields, I want the records were the first 3 fields
match and the fourth field does not.
Thks
Can I suggest you expand a little on what you are trying to do. What you have
asked has no real explanation. It would help people to assist you if youe
describe more fully what you are trying to do.
--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B
- Show quoted text -
Thks for responding. I'm doing a duplicate query, as an example of a
customer table, I want to find all the John Doe born in 1960 who live
in a different state. So field1, field2 and field3 match, field4 does
not.
table.field4
Is there a reason you aren't doing this in a spreadsheet?
Are you saying you want to know which records have values like:
ColumnA = ColumnB = ColumnC <> ColumnD
You could try a query to get those, but without more information about what,
precisely, is being stored in those fields, this is only a wild hunch...
More info, please...
Regards
Jeff Boyce
Microsoft Office/Access MVP
- Show quoted text -
Try this query.
SELECT A.*
FROM TableName as A INNER JOIN TableName as B
On A.Name = B.Name
AND A.Address = B.Address
AND A.Phone = B.Phone
WHERE A.Age <> B.Age
ORDER BY A.Name, A.Address, A.Phone, A.Age
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
- Show quoted text -
I think that the following should work.
SELECT A.First, A.Middle, A.Last
FROM [YourTable] as A INNER JOIN [YourTable] As B
ON A.First = B.First
AND A.Last = B.Last
WHERE A.Middle <> B.Middle
If this fails, you might post back and explain what results you got and
why they are different from what you want.
For instance, if one name had a null value for Middle then you would not
get the results you wanted. However, that could be rectified by
changing the WHERE clause to
Where A.Middle <. B.Middle
OR A.Middle is Null and B.Middle is Not Null
OR A.Middle is Not Null and B.Middle is Null
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
Let me add a sample:
First - Middle - Last
Al - R - Johnson
Bob - M - Doe
Fred - J - Smith
Bob - W - Doe
Marc - - Lewis
Al - R - JohnsonI would like a query of those with the same first & last, but a
different middle, so the query will only show:
Bob - M - Doe
Bob - W - DoeThank you very much for all your help.
Bill- Hide quoted text -
- Show quoted text -
I think that the following should work.
SELECT A.First, A.Middle, A.Last
FROM [YourTable] as A INNER JOIN [YourTable] As B
ON A.First = B.First
AND A.Last = B.Last
WHERE A.Middle <> B.Middle
If this fails, you might post back and explain what results you got and
why they are different from what you want.
For instance, if one name had a null value for Middle then you would not
get the results you wanted. However, that could be rectified by
changing the WHERE clause to
Where A.Middle <. B.Middle
OR A.Middle is Null and B.Middle is Not Null
OR A.Middle is Not Null and B.Middle is Null
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
- Show quoted text -Let me add a sample:
First - Middle - Last
Al - R - Johnson
Bob - M - Doe
Fred - J - Smith
Bob - W - Doe
Marc - - Lewis
Al - R - Johnson
I would like a query of those with the same first & last, but a
different middle, so the query will only show:
Bob - M - Doe
Bob - W - Doe
Thank you very much for all your help.
Bill- Hide quoted text -
John, your solution worked perfectly on our test table, thks. We are
looking to expand our Access & SQL knowledge, what options could you
recommend? Again thank you very much.
Bill
SQL Queries for Mere Mortals is a book I liked to help me learn more about SQL
queries.
As far as books on Access, my best suggestion is go to a book store and look
through the books they have on the subject. Use the index and try to locate a
section that helps you solve a current problem. See if you are comfortable
with understanding what is there.
One of my best resources for learning was (and still is) these newsgroups..
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
[email protected] said:I think that the following should work.
SELECT A.First, A.Middle, A.Last
FROM [YourTable] as A INNER JOIN [YourTable] As B
ON A.First = B.First
AND A.Last = B.Last
WHERE A.Middle <> B.Middle
If this fails, you might post back and explain what results you got and
why they are different from what you want.
For instance, if one name had a null value for Middle then you would not
get the results you wanted. However, that could be rectified by
changing the WHERE clause to
Where A.Middle <. B.Middle
OR A.Middle is Null and B.Middle is Not Null
OR A.Middle is Not Null and B.Middle is Null
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
Let me add a sample:
First - Middle - Last
Al - R - Johnson
Bob - M - Doe
Fred - J - Smith
Bob - W - Doe
Marc - - Lewis
Al - R - Johnson
I would like a query of those with the same first & last, but a
different middle, so the query will only show:
Bob - M - Doe
Bob - W - Doe
Thank you very much for all your help.
Bill- Hide quoted text -
- Show quoted text -John, your solution worked perfectly on our test table, thks. We are
looking to expand our Access & SQL knowledge, what options could you
recommend? Again thank you very much.
Bill- Hide quoted text -
- Show quoted text -