So I have 2 tables. Employee and Draft_Employee. They are identical, except that properties in Draft_Employee allow nulls.
The reason for the 2 identical tables, is that the draft_Employee is a table used for an import procedure – it is a tempoary container. We don’t want the data messed up with the production employees.
Now, when a employee has to be imported, the system has to check if the employee already exists in the database.
First it see’s if it can find an employee in Employee table with the same EmpID.
If found, it will look at employee in Draft_Employee and find the properties which are NULL or EMPTY. It will then take the value for the same field in Employee table and put it into the empty or NULL fields in draft_Employee
empID name something1 something2 | empID name something1 something2
----- ---- ---------- ---------- | ---- ---- ---------- -----------
1 Casper blahblah blahblah2 | 2 Michael NULL text2fs
2 Michael txttxt |
Right is Employee and left is Draft_Employee.
I want an sql query that produces
empID name something1 something2
----- ---- ---------- ----------
2 Michael txttxt text2fs
The closest I have come, is with LEFT OUTER JOIN but it gives me data from both tables
EDIT: My query. I did not use it before, because the spelling is danish.
SELECT * FROM Kladde_Ressource
LEFT OUTER JOIN Ressource
ON Ressource.RessourceID = Kladde_Ressource.RessourceID
WHERE Kladde_Ressource.EAN = ''
OR Kladde_Ressource.navnLang = ''
OR Kladde_Ressource.navnKort = ''
etc...
I don’t entirely grasp your requirement so I am basing my query on the data and required result you’ve posted.
As to get the results merged into one result set
Statement