472,807 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,807 software developers and data experts.

Combining two tables

I want to combine two tables into one. I have a table with all the field
definitions from two other tables. I now need to update this new table with
the data from the other two tables.However both the existing tables have 2
fields that are common ie txtmonthlabel and txtcompany. I tried running an
append query from each table but I got duplicate records from the two tables
eg if 1 table had data for Company A and the other table also had data for
Company A I got two records whereas I only want one record with the combined
data. The same thing happens with txtmonthlabel.
Can anyone help me here?
TIA
Tony Williams
Nov 13 '05 #1
4 11464
I think that what you need to do is copy one of the original tables,
and then add the extra fields to the copy. Then run an append query to
add in the records from the other table.

On Thu, 16 Dec 2004 11:14:26 +0000 (UTC), "Tony Williams"
<tw@tcpinvalid.com> wrote:
I want to combine two tables into one. I have a table with all the field
definitions from two other tables. I now need to update this new table with
the data from the other two tables.However both the existing tables have 2
fields that are common ie txtmonthlabel and txtcompany. I tried running an
append query from each table but I got duplicate records from the two tables
eg if 1 table had data for Company A and the other table also had data for
Company A I got two records whereas I only want one record with the combined
data. The same thing happens with txtmonthlabel.
Can anyone help me here?
TIA
Tony Williams


Nov 13 '05 #2
Thanks Dave I've tried that but I get duplicates. Eg One table has say 1500
records the other has 500. When I combine them I should still have 1500 but
I get 2000
So the data is not being "merged" just added as new records. I've been at
this for three days now and I didn't think something that sounded
simplecould be so difficult!
Thanks
Tony
"Dave Bradshaw" <"dave"&"."&"bradshaw"&"@"&"bowbros"&"."&"co"&"."& "uk">
wrote in message news:7f********************************@4ax.com...
I think that what you need to do is copy one of the original tables,
and then add the extra fields to the copy. Then run an append query to
add in the records from the other table.

On Thu, 16 Dec 2004 11:14:26 +0000 (UTC), "Tony Williams"
<tw@tcpinvalid.com> wrote:
I want to combine two tables into one. I have a table with all the field
definitions from two other tables. I now need to update this new table withthe data from the other two tables.However both the existing tables have 2fields that are common ie txtmonthlabel and txtcompany. I tried running anappend query from each table but I got duplicate records from the two tableseg if 1 table had data for Company A and the other table also had data forCompany A I got two records whereas I only want one record with the combineddata. The same thing happens with txtmonthlabel.
Can anyone help me here?
TIA
Tony Williams

Nov 13 '05 #3
table1 is the table you want to append to
table2 is the table with some but not all duplicate data.
company is the field that is the same in both tables.

INSERT INTO table1
(
SELECT table2.*
FROM table2 LEFT JOIN table1 ON table1.company = table2.company
WHERE table2.company Is Null
)

Your situation may be a little different. If this does not work as planned,
try this:

In the query design part of Access, visually construct a SELECT query to get
the results you want. Then you can change it to a "Make Table" query if you
want. (Not sure if you want a new table3, or just to insert the
non-duplicated records into table1) . Then you can view the SQL, and copy it
to VBA, or run it as a stored query from code.

Darryl Kerkeslager

"Tony Williams" <tw@tcpinvalid.com> wrote in message
news:cp**********@titan.btinternet.com...
Thanks Dave I've tried that but I get duplicates. Eg One table has say 1500 records the other has 500. When I combine them I should still have 1500 but I get 2000
So the data is not being "merged" just added as new records. I've been at
this for three days now and I didn't think something that sounded
simplecould be so difficult!
Thanks
Tony
"Dave Bradshaw" <"dave"&"."&"bradshaw"&"@"&"bowbros"&"."&"co"&"."& "uk">
wrote in message news:7f********************************@4ax.com...
I think that what you need to do is copy one of the original tables,
and then add the extra fields to the copy. Then run an append query to
add in the records from the other table.

On Thu, 16 Dec 2004 11:14:26 +0000 (UTC), "Tony Williams"
<tw@tcpinvalid.com> wrote:
I want to combine two tables into one. I have a table with all the fielddefinitions from two other tables. I now need to update this new table withthe data from the other two tables.However both the existing tables
have
2fields that are common ie txtmonthlabel and txtcompany. I tried running anappend query from each table but I got duplicate records from the two tableseg if 1 table had data for Company A and the other table also had data forCompany A I got two records whereas I only want one record with the combineddata. The same thing happens with txtmonthlabel.
Can anyone help me here?
TIA
Tony Williams


Nov 13 '05 #4
Thanks Darryl first suggestion worked OK
Tony
"Darryl Kerkeslager" <Ke*********@comcast.net> wrote in message
news:Rr********************@comcast.com...
table1 is the table you want to append to
table2 is the table with some but not all duplicate data.
company is the field that is the same in both tables.

INSERT INTO table1
(
SELECT table2.*
FROM table2 LEFT JOIN table1 ON table1.company = table2.company
WHERE table2.company Is Null
)

Your situation may be a little different. If this does not work as planned, try this:

In the query design part of Access, visually construct a SELECT query to get the results you want. Then you can change it to a "Make Table" query if you want. (Not sure if you want a new table3, or just to insert the
non-duplicated records into table1) . Then you can view the SQL, and copy it to VBA, or run it as a stored query from code.

Darryl Kerkeslager

"Tony Williams" <tw@tcpinvalid.com> wrote in message
news:cp**********@titan.btinternet.com...
Thanks Dave I've tried that but I get duplicates. Eg One table has say

1500
records the other has 500. When I combine them I should still have 1500

but
I get 2000
So the data is not being "merged" just added as new records. I've been at
this for three days now and I didn't think something that sounded
simplecould be so difficult!
Thanks
Tony
"Dave Bradshaw" <"dave"&"."&"bradshaw"&"@"&"bowbros"&"."&"co"&"."& "uk">
wrote in message news:7f********************************@4ax.com...
I think that what you need to do is copy one of the original tables,
and then add the extra fields to the copy. Then run an append query to
add in the records from the other table.

On Thu, 16 Dec 2004 11:14:26 +0000 (UTC), "Tony Williams"
<tw@tcpinvalid.com> wrote:

>I want to combine two tables into one. I have a table with all the field >definitions from two other tables. I now need to update this new

table with
>the data from the other two tables.However both the existing tables have
2
>fields that are common ie txtmonthlabel and txtcompany. I tried

running an
>append query from each table but I got duplicate records from the two

tables
>eg if 1 table had data for Company A and the other table also had
data for
>Company A I got two records whereas I only want one record with the

combined
>data. The same thing happens with txtmonthlabel.
>Can anyone help me here?
>TIA
>Tony Williams
>



Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: frizzle | last post by:
Hi, I know this might sound strange but i think(/hope) it's quite simple: I'm running 2 queries in a mysql DB, first one returns 20 results. Now how can i echo results from the second query...
2
by: Ron Sorrell | last post by:
I have a requirment to take data from a large set of tables where the total number of these tables may change on a regular baisis and output into another table. All the tables willl have the...
2
by: Kenneth Fosse | last post by:
Hi. I'm currently working on a project which involves the creation of a web page which reports selected data to customers from two back-end systems. I use ASP script language on IIS, the server...
0
by: Bob C. | last post by:
I am considering combining one large Access db and several small Access db's into a single SQL Server 2000 db. The small db's serve separate but related functions in our operation, and they all...
2
by: Max | last post by:
Hello everyone, I have a task of combining two tables: tblPatient and tblSolution, related by a KEY field in a one-to-many relationship from tbl Patient to tblSolution, respectively. So, I have...
7
by: Frank | last post by:
Hi there, I'm trying to generate a report for an old database and I'm having trouble coming up with an elegant way of going about it. Using cursors and other 'ugly' tools I could get the job done...
3
by: cjbutler | last post by:
Hi, I am using MS Access 2003 on a Windows XP platform. I am wondering what the best way is to go about combining data from 4 tables. Here is a sample from all 4 tables, with what I would like...
2
by: J055 | last post by:
Hi I need to search a number of DataTables within a DataSet (with some relationships) and then display the filtered results in a GridView. The Columns that need to be displayed come from 2 of...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.