Currently my SQL below is finding all Sell Item that are “Y”, and retrieving the values from the tables and appending the information to one table called AlldataTogether. Which works fine thanks to all the user who helped me out on this forum.
This is where I need your help again
If Sell is already “Y” in the tables (Sell Information NJ or Sell Information CA), I only want the Null Value by Item from CHINA Import Information to be filter by the field Location “CSA”. For this example Toy Car is already “Y” so I would need Acces. And LED Light to append to the AllDataTogether
But this is the tricky part I also don’t understand how to do
All the tables are related by Item, I need to retrieve the following information and append to AlldataTogether for the Null Values from CHINA Import Information as follow
Item: Null value by Item from CHINA Important Information based on if Sell is Y
Location: Location pulled from CHINA Important Information by Item
Supplier: supplier pulled from CHINA Important Information by Item
Sell: If Value is Null from the CHINA Important, I want the text string to say “CHINA”
Account Manger: Account Manger pulled from CHINA Important Information by Item
Stock: The value of stock can be either in Sell Data CA or Sell Data NJ
Total: The value of Total can be either in Sell Data CA or Sell Data NJ
Code: Code pulled from either Sell Information NJ or Sell Information CA by item.
Code:
INSERT INTO AllDataTogether ( DateEnter )SELECT RawInfoUNION.*, [Enter Date] AS DateEnter
FROM (SELECT [Sell Information NJ].[Item],Location, [Supplier], [Sell], [Account Manger],[Stock],[Total],Code FROM [Sell Information NJ] LEFT JOIN [Sell Data NJ] ON [Sell Information NJ].[Item] = [Sell Data NJ].[Item]
Union Select [Sell Information CA].[Item], Location, [Supplier], [Sell], [Account Manger],[Stock],[Total],Code FROM [Sell Information CA] LEFT JOIN [Sell Data CA] ON [Sell Information CA].[Item] = [Sell Data CA].[Item]) AS RawInfoUNION
WHERE ((RawInfoUnion.[Sell]="Y"));