473,320 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Merge 2 tables

This is a common problem and probably been asked before but I searched the forum without luck.

I have 2 tables for January and February data with identical structure. I want to add only the new records from February to the January table with a SQL query.

EX: tables with 2 fields ID and Text
January table
ID Text
2 two
4 four
5 five

February table
ID Text
1 One
4 Four
5 Five

Result:
January table
ID Text
1 One
2 two
4 four
5 five
Mar 4 '08 #1
3 1187
amitpatel66
2,367 Expert 2GB
This is a common problem and probably been asked before but I searched the forum without luck.

I have 2 tables for January and February data with identical structure. I want to add only the new records from February to the January table with a SQL query.

EX: tables with 2 fields ID and Text
January table
ID Text
2 two
4 four
5 five

February table
ID Text
1 One
4 Four
5 Five

Result:
January table
ID Text
1 One
2 two
4 four
5 five
Simple INSERT query would do:

Expand|Select|Wrap|Line Numbers
  1.  
  2. INSERT INTO january SELECT * FROM february WHERE id NOT IN (SELECT id FROM january)
  3.  
  4.  
Mar 5 '08 #2
Thank you very much!
Mar 5 '08 #3
amitpatel66
2,367 Expert 2GB
Thank you very much!
You are Welcome :) .
Mar 5 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Nils | last post by:
Hello, my problem: I merged about 1.000 Tables with Create table name (variables) type=merge union=(table1,table2,...,table1000); MySQL now creates a tables, but I can't open it....
6
by: campwes | last post by:
Hey, all. I'm trying to develop a C# app that creates Word 2003 mail merge documents with an Oracle 9i database as the datasource. I used the following as an example of how I can start out: ...
0
by: Brett Romero | last post by:
If I have a dataset with one table and want to merge another table, how does merge know which column to match rows on in each table? For example Table 1: personid firstname lastname address
3
by: cdelarte | last post by:
I would like to be able to mail merge records from multiple mysql tables using a simple template, preferably via a command line script. MSWord mail merge via ODBC will not work for me as it only...
16
by: UDBDBA | last post by:
Hi All: I need some clarification on a MERGE statement. The database is on V8 FP12 (AIX) 64bit. The source table is tableA. The target is a View "FACT" with UNION ALL because of the 512 Gig...
3
by: John Cosmas | last post by:
I have a DATATABLE which I have populated in my application, and I need it written out to a particular table I specify in my ACCESS database. My code works to the point of the MERGE and UPDATE,...
5
by: Mark Chambers | last post by:
Hi there, Can anyone explain the following (very) simple scenario. 1) I make an exact copy of my "DataSet" and delete one record from a given table (in the copy) 2) I invoke...
7
by: giladp1 | last post by:
I found Albert Kallal's great "Super easy Word Merge" code in his site at: http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html Thanks Albert so much for sharing this. I am looking...
0
by: Dave.Womer | last post by:
All, I'm having an issue merging datasets. It seems everytime I peform a merge of new data on existing data all of the rows of the existing data are modified even if the new data does not...
1
by: joproulx | last post by:
Hello all, Here is my problem: I am trying to merge 2 datasets but I don't want to overwrite rows that are already modified in my working dataset. Example: I have one Dataset with only one...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.