I have multiple column that i need to compare and join.
This is the table i need to use to compare others.
MainTable
--Check Number-- --Reimbursement--
-----1000-----------5800.11
-----1001-----------5802.12
-----1002-----------5801.13
-----1003-----------5800.11
-----1004-----------5804.14
Multiple tables like this that I need to compare
ChildTable1
--Check Number --Name----Total Cash---Bonus-
-----1003------John-------5500.11------300
-----1000------Jane-------5502.12------300
-----1002------Joe--------5501.13------300
-----1001------Jay--------5500.11------300
-----1004------Janie------5504.14------300
ChildTable2
--Check Number --Name----Total Cash---Bonus-
-----1013------John-------5500.11------300
-----1010------Jane-------5502.12------300
-----1002------Joe--------5501.13------300
-----1011------Jay--------5500.11------300
-----1014------Janie------5504.14------300
The End Result should be like this
--Check Number --Name----Total Cash---Bonus-----Reimbursement--
-----1003------John-------5500.11------300-----------5800.11
-----1000------Jane-------5502.12------300-----------5800.11
-----1002------Joe--------5501.13------300-----------5801.13
-----1001------Jay--------5500.11------300-----------5802.12
-----1004------Janie------5504.14------300-----------5804.14
not
--Check Number --Name----Total Cash1---Bonus1---------Total Cash2---Bonus2-----Reimbursement--
-----1003--------John-------5500.11------300------------------NULL------NULL-----------5800.11
-----1000--------Jane-------5502.12------300------------------NULL------NULL-----------5800.11
-----1002--------Joe--------5501.13------300------------------NULL------NULL-----------5801.13
-----1001--------Jay--------5500.11------300------------------NULL------NULL-----------5802.12
-----1004--------Janie------5504.14------300------------------NULL------NULL-----------5804.14
So I need to compare all tables against the Main table and join only the tables with the same check number
You can do this as two separate queries and UNION them together: