Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with excel query

Status
Not open for further replies.

hirasif

IS-IT--Management
Nov 27, 2012
4
AU
Hi All,
I need help to write a query to get the values from two tables. Both tables have the same fields. Most of the records are mattched. My query should append the unmatched records from table2 to table1.

Please help!!!
Hirasif
 
Hi,
Code:
Select distinct *
From
(
Select *
From table1

Union all

Select *
From table2
)

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks SkipVought.

This code is actually giving me the query result incorporating both tables. But I want to append the additional rows from table2 at the end of Table2.

Can you please help me with this?
Hirasif
 
What have you tried?

Table order ought to be able to be achieved by sorting, yes?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi SkipVought,

I am sorry to confuse you. I meant to say that I am trying to do it in Access, NOT in Excel.

Hirasif
 
So let me understant it:
Table1 has 5 records, Table2 has 15 records.
5 records from table1 are in table2. You want to take 10 records from table2 that are NOT in table1 and add them to table1?

If so,
1. why do you want to have 2 tables with the same data?
2. how about very simple:
DELETE FROM Table1
INSERT INTO Table1 (SELECT * FROM Table2)

Have fun.

---- Andy
 
Hi Andrzejek,

I have two tables (Baseline run, Regression run) from two run of similar pay. Fields on these tables are EmpID, Name, ElementClassification, ElementReportingName, ElementName, Amount). Data on these two tables might be similar, or different. I need to write a query to reconsile this two tables and identify the difference if any.
Hirasif
 
You would be better off if you would provide a simple example of a few records in those 2 tables to represent your issue.
Something like:

Baseline table
[pre]
EmpID Name EleClass
12 Joe ABC
13 Sus XYZ
14 Rob ABC
[/pre]

Regression table
[pre]
EmpID Name EleClass
12 Joe ABC
25 Bob DEF
[/pre]
and specify what should happen, which records from what table should be copied to what table, and what are the criteria of why these records and not the other records.

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top