Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have two table from which i am importing Data using SQl
Query. Both table got several identical filelds while some fields do not appear in both (some fields are in table A but not in table B and vice versa) Is it possible that I can get data from both tables to a single sheet either with identical fields only or even including un identical fields? Identical fields only will also help me. any code example will be much helpful Thanks Soniya |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Soniya" wrote ...
I have two table from which i am importing Data using SQl Query. Both table got several identical filelds while some fields do not appear in both (some fields are in table A but not in table B and vice versa) Is it possible that I can get data from both tables to a single sheet either with identical fields only or even including un identical fields? Identical fields only will also help me. Rows common to both tables: SELECT T1.MyKeyCol, T1.MyDataCol FROM Table1 T1 INNER JOIN Table2 T2 ON T1.MyKeyCol = T2.MyKeyCol; Rows in table1 that are not in table2: SELECT T1.MyKeyCol, T1.MyDataCol FROM Table1 T1 LEFT JOIN Table2 T2 ON T1.MyKeyCol = T2.MyKeyCol WHERE T2.MyKeyCol IS NULL; Rows in table2 that are not in table1: SELECT T2.MyKeyCol, T2.MyDataCol FROM Table1 T1 RIGHT JOIN Table2 T2 ON T1.MyKeyCol = T2.MyKeyCol WHERE T1.MyKeyCol IS NULL; Rows from both tables, no duplicates: SELECT T1.MyKeyCol, T1.MyDataCol FROM Table1 T1 UNION SELECT T2.MyKeyCol, T2.MyDataCol FROM Table2 T2; Rows from both tables, including duplicates: SELECT T1.MyKeyCol, T1.MyDataCol FROM Table1 T1 UNION ALL SELECT T2.MyKeyCol, T2.MyDataCol FROM Table2 T2 ORDER BY 1; Jamie. -- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can i join these two formulas? | Excel Worksheet Functions | |||
Join tables like inner join in Access | Excel Discussion (Misc queries) | |||
How do I join two workbooks into one pivot table? | Excel Worksheet Functions | |||
Can you join multiple databases using a pivot table? | Excel Discussion (Misc queries) | |||
Msquery and join | Excel Discussion (Misc queries) |