M
muralibox
Below is the sample SQL we basically use to compare fields from two tables
and display the result. However when I have to convert this to MS ACCESS
query, I found it difficult as SELECT CASE works differently in MS ACCESS. I
was able to compare just one condition and throw result using below MS ACCESS
syntax.
SQL
Select Table1.Field1, Table1.Field2, Table1.Field3, Table1.Field4, Table1.
Field5, Table2.Field1, Table2.Field2, Table2.Field3, Table2.Field4,Table2.
Field5,
Case when Table1.Field1<>Table2.Field1 then ‘Field1_not_matched’
when Table1.Field2<>Table2.Field2 then ‘Field2_not_matched’
when Table1.Field3<>Table2.Field3 then ‘Field3_not_matched’
when Table1.Field4<>Table2.Field4 then ‘Field4_not_matched’
else ‘All_Matched’
END AS result
From table1 inner join table 2 on table1.field5=table2.field5
MS ACESS
IIF(Table1.field1=Table2.Field1,’Field1_matched’,’Field1_Not_matched’) AS
result
I want to see the result more appropriate, if field1 not matched my result
column should indicate field1 not matched and if field2 is not matched then
my result column should indicate field2 not matched and so on. In case more
than one field not matched in a single row then it should display the first
mismatched field message. This is how the SQL query works and I want to see
this code converted to MS ACCESS.
So the query result should look like this
Table1.field1 Table1.field2 Table1.field3 Table1.field4 Table2.Field1 Table2.
field2 Table2.field3 Table2.field4 Result
123 Sarala Palos Hills IL 123 Sarala Palos Hills IL All_Matched
111 Ashok Columbus OH 110 Ashok Columbus OH Field1_notmatched
453 Bhar Orlando FL 444 Bhargavi Orlando FL Field1_notmatched
422 Ragu Auroraa IL 422 Ragu Aurora FL Field3_notmatched
Please please give me a solution for this .............
my email is (e-mail address removed)
thanks for your Help.
and display the result. However when I have to convert this to MS ACCESS
query, I found it difficult as SELECT CASE works differently in MS ACCESS. I
was able to compare just one condition and throw result using below MS ACCESS
syntax.
SQL
Select Table1.Field1, Table1.Field2, Table1.Field3, Table1.Field4, Table1.
Field5, Table2.Field1, Table2.Field2, Table2.Field3, Table2.Field4,Table2.
Field5,
Case when Table1.Field1<>Table2.Field1 then ‘Field1_not_matched’
when Table1.Field2<>Table2.Field2 then ‘Field2_not_matched’
when Table1.Field3<>Table2.Field3 then ‘Field3_not_matched’
when Table1.Field4<>Table2.Field4 then ‘Field4_not_matched’
else ‘All_Matched’
END AS result
From table1 inner join table 2 on table1.field5=table2.field5
MS ACESS
IIF(Table1.field1=Table2.Field1,’Field1_matched’,’Field1_Not_matched’) AS
result
I want to see the result more appropriate, if field1 not matched my result
column should indicate field1 not matched and if field2 is not matched then
my result column should indicate field2 not matched and so on. In case more
than one field not matched in a single row then it should display the first
mismatched field message. This is how the SQL query works and I want to see
this code converted to MS ACCESS.
So the query result should look like this
Table1.field1 Table1.field2 Table1.field3 Table1.field4 Table2.Field1 Table2.
field2 Table2.field3 Table2.field4 Result
123 Sarala Palos Hills IL 123 Sarala Palos Hills IL All_Matched
111 Ashok Columbus OH 110 Ashok Columbus OH Field1_notmatched
453 Bhar Orlando FL 444 Bhargavi Orlando FL Field1_notmatched
422 Ragu Auroraa IL 422 Ragu Aurora FL Field3_notmatched
Please please give me a solution for this .............
my email is (e-mail address removed)
thanks for your Help.