Hi,
I have 3 tables of data created from different sources, each with the same 2 fields & I wanted to fill the 2nd field of another table with the data on condition.
The condition is because some sources have a higher known accuracy than other sources.
So, every table has a field named "SupplierCode" & a field named "SupplierName", There are 3 source tables (SourceTable1, SourceTable2, SourceTable3), & a final output table (ResultTable) which contains the desired SupplierCode's.
Where there's a match with ResultTable.SupplierCode & each of the SourceTable?.SupplierCode's, I want the ResultTable.SupplierName to be populated with SourceTable3.SupplierName data, then to be populated with SourceTable2.SupplierName data, then with SourceTable3.SupplierName data. But only if there's data.
So what I'm trying to say is SourceTable1.SupplierName data is most desired & SourceTable3.SupplierName data is least desired, but better than nothing. But I don't want a blank SourceTable1.SupplierName record to overwrite populated SourceTable3.SupplierName data. Sort of "only overwrite it if you've got data" condition.
I guess another way is to populate ResultTable.SupplierName with SourceTable1.SupplierName, then only populate SourceTable2.SupplierName into ResultTable.SupplierName if that record is still empty, & so on...
I hope this is making sense, sorry if it's vague. I have searched previous help here but I can't seem to make it fit.
My SQL statement so far is:
SELECT ResultTable.SupplierCode, ResultTable.SupplierName, SourceTable1.SupplierName, SourceTable2.SupplierName, SourceTable3.SupplierName
FROM ((ResultTable LEFT JOIN SourceTable1 ON ResultTable.SupplierCode = SourceTable1.SupplierCode) LEFT JOIN SourceTable2 ON ResultTable.SupplierCode = SourceTable2.SupplierCode) LEFT JOIN SourceTable3 ON ResultTable.SupplierCode = SourceTable3.SupplierCode;
This doesn't put the data into 1 column though (it shows all 3 sources), & it won't apply the condition, of course. Thanks in advance.
Dave.