Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello All,
I am using a query to get data from two tables using UNION All. How can I add a field to the joined data to show the data from which table? Something like For eg. If I say select field1, field2, field 3 FROM Table1 Union all field1, field2, field3 FROM Table2 Then can I add a field say field4 (which is not in either table) and add "A" if the data is from Table1 and "B" if the data from Table2 ? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
SELECT field1, field2, field3, 'A' as tableId FROM Table1
UNION ALL SELECT field1, field2, field3, 'B' as tableId FROM Table2 HTH -- AP "Abdul" a écrit dans le message de oups.com... Hello All, I am using a query to get data from two tables using UNION All. How can I add a field to the joined data to show the data from which table? Something like For eg. If I say select field1, field2, field 3 FROM Table1 Union all field1, field2, field3 FROM Table2 Then can I add a field say field4 (which is not in either table) and add "A" if the data is from Table1 and "B" if the data from Table2 ? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pivot table to query data in a set range | Excel Discussion (Misc queries) | |||
Data Points Joined by Spiral !! | Charts and Charting in Excel | |||
Pivot Table Data Field Query | Excel Worksheet Functions | |||
Userform web Data query table | Excel Programming | |||
Append Data to Table after Web Query | Excel Programming |