Hi,
All my data tables are in same layout that is column order and field name are exactly same and i have all my data in ms access. Just to give you example i had asked my friend to write a query in sql server 2005 which exactly meets my requirement. I am little bit confused with your last post. Can you please provide me with a sample code for my excel macro. Let me once again brief you the whole thing.
For example :
Following are the things which i have in my data :
a) I have 2 data tables in my ms access file. Following are the names of the same:
1) Japan
2) Asia
b) i have two more tables in the same ms access file which are as follows :
1) Cost Center Mapping or COST_CENTER_MASTER
2) Cost Element Mapping or COST_ELEMENT_MASTER
c) All 4 of the above tables have following fields common in them.
1) COST_CENTRE_CODE : which is common in Cost Center Mapping and my data tables that is both Japan and Asia
2) UNIQUEIDENTITY : which is common in Cost Element Mapping and my data tables that is both Japan and Asia
Now what i am looking for and what should be the output of my macro. Following is the code which was been provided by you in 08-09-09 post.
SELECT a.*
FROM [Japan] AS a
INNER JOIN [Cost Center Mapping] AS b
ON a.[COST_CENTRE_CODE] = b.[COST_CENTRE_CODE]
WHERE b.[Product] = 'ABC';
As far as the above code is concerned it's working fine. I just want to add an additional criteria to the same. In the above code you have filtered the data from Japan table for Product "ABC" on the basis of the common field "COST_CENTRE_CODE" present in both Cost Center Mapping and Japan table. Now i want you to add an additional criteria to the above code that is it should also look for FSI "XYZ" in the same data table on the basis of "UNIQUEINDENTITY" field / column which is common in both Japan table and Cost Element Mapping.
Apart from this i want to get the same output from multiple table as of now if you see we have 2 tables that is Japan and Asia. So Please provide me a separate example which will use Union function and give the consolidated output for the both the tables. Now as both the table structures are exactly same, Please provide me a example in which i don't have to repeat Product and FSI looking criteria again and again for each table. I want something like below :
HTML Code:
SELECT * FROM (
SELECT * FROM Japan
UNION ALL
SELECT * FROM Asia
) subQry
WHERE Product = 'ABC' and FSI = 'XYZ'
Note : Look for the Product "XYZ" data on the basis of "COST_CENTRE_CODE" field which is common in datatables and Cost Center Mapping table and further filter / look for the FSI "XYZ" data on the basis of "UNIQUEIDENTITY" field which is common in datatables and Cost Element Mapping" in the same datatables
Thanks a lot for your help in advance.
