can some one help me with this. I want a Query, where it will compare two tables say Table 1 as Controloperator and Table 2 as Teamleader. Both have same Fields - Date completed, Type of control and Name. if both the values in the tables are same then it should throw a message saying approved. might have records not in table2
and table2 might also have records not in table1
If there are mismatch then mismatches should be come as a result of the query with the table name. Say record 1 is missing in Table1. can some help.
Below is the Query :
SELECT c.ID, c.Date_complete d, c.Type_of_Contr ol, IIf(Teamleader. ID Is Null Or Controloperator .ID Is Null,"Not Matching","Appr oved") AS Status
FROM (Controloperato r RIGHT JOIN (SELECT * FROM Controloperator UNION select * from Teamleader) AS c ON (Controloperato r.Type_of_Contr ol = c.Type_of_Contr ol) AND (Controloperato r.Date_complete d = c.Date_complete d) AND (Controloperato r.ID = c.ID)) LEFT JOIN Teamleader ON (c.Type_of_Cont rol = Teamleader.Type _of_Control) AND (c.Date_complet ed = Teamleader.Date _completed) AND (c.ID = Teamleader.ID);
It is showing error message as "The Specified field 'Controloperato r.Date_complete d' could refer to more than one table listed in the FROM clause of your SQL statement. Kindly help. And I also need the table name from where the mismatch happend should also reflect in my query.
and table2 might also have records not in table1
If there are mismatch then mismatches should be come as a result of the query with the table name. Say record 1 is missing in Table1. can some help.
Below is the Query :
SELECT c.ID, c.Date_complete d, c.Type_of_Contr ol, IIf(Teamleader. ID Is Null Or Controloperator .ID Is Null,"Not Matching","Appr oved") AS Status
FROM (Controloperato r RIGHT JOIN (SELECT * FROM Controloperator UNION select * from Teamleader) AS c ON (Controloperato r.Type_of_Contr ol = c.Type_of_Contr ol) AND (Controloperato r.Date_complete d = c.Date_complete d) AND (Controloperato r.ID = c.ID)) LEFT JOIN Teamleader ON (c.Type_of_Cont rol = Teamleader.Type _of_Control) AND (c.Date_complet ed = Teamleader.Date _completed) AND (c.ID = Teamleader.ID);
It is showing error message as "The Specified field 'Controloperato r.Date_complete d' could refer to more than one table listed in the FROM clause of your SQL statement. Kindly help. And I also need the table name from where the mismatch happend should also reflect in my query.
Comment