L
Leslie Isaacs
Hello All
I have two large tables {each with around 4500 records}:
NHSPA with the following fields
[firstname]
[surname]
[dob]
[comdate]
[sdnumber]
[ninumber]
and STAFFS with the following fields
[first_name]
[surname]
[dob]
[com_date]
[sd_number]
[ni_number]
I need a query that will check for matched records in the tables, but the
trouble is that it is unknown which - if any - of the fields match exactly.
The rule for determining a match would be that one or more of the following
3 conditions must be met:
condition 1
[firstname] = [first_name] and
[surname] = [surname] and
[dob] = [dob]
or
condition 2
[sdnumber] = [sd_number]
or
condition 3
[ninumber] = [ni_number]
The query needs to identify all matched records, and for these records it
needs to return any mis-matches in the other fields.
e.g.
For all matches identified under condition 1 the query must return any
records where
[comdate] <> [com_date]
or
[sdnumber] <> [sd_number]
or
[ninumber] <> [ni_number]
I think I can do this with 3 seperate queries {one corresponding to each
condition}, but it would be better if it could be done with one query -
partly because I need to display all the results in one report. I cannot
work out how to do this though.
Hope someone can help.
Many thanks
Les
I have two large tables {each with around 4500 records}:
NHSPA with the following fields
[firstname]
[surname]
[dob]
[comdate]
[sdnumber]
[ninumber]
and STAFFS with the following fields
[first_name]
[surname]
[dob]
[com_date]
[sd_number]
[ni_number]
I need a query that will check for matched records in the tables, but the
trouble is that it is unknown which - if any - of the fields match exactly.
The rule for determining a match would be that one or more of the following
3 conditions must be met:
condition 1
[firstname] = [first_name] and
[surname] = [surname] and
[dob] = [dob]
or
condition 2
[sdnumber] = [sd_number]
or
condition 3
[ninumber] = [ni_number]
The query needs to identify all matched records, and for these records it
needs to return any mis-matches in the other fields.
e.g.
For all matches identified under condition 1 the query must return any
records where
[comdate] <> [com_date]
or
[sdnumber] <> [sd_number]
or
[ninumber] <> [ni_number]
I think I can do this with 3 seperate queries {one corresponding to each
condition}, but it would be better if it could be done with one query -
partly because I need to display all the results in one report. I cannot
work out how to do this though.
Hope someone can help.
Many thanks
Les