473,394 Members | 1,770 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,394 software developers and data experts.

Two tables

Hiya

I have a problem which I'm working on which I hope someone can help with. I
have two tables in a database. For the sake of argument, let us call them
Table1 and Table2.

For each record in Table1, I want to write a record in Table2 where the
record will be made up of information from the corresponding record in
Table1.

If the application is shutdown and additional records are added to Table1,
the next time the application is run, I want to add extra records to Table2
from these "new" records; preferbly by not completely re-writing Table2 i.e.
appending new records to its end.

Obviously, the application will need to able to "know" which are the new
records.

Can anybody help with this? Some example code would be most appreciated.

Thanks in advance

Geoff
Nov 21 '05 #1
4 879
Geoff,

In my opinion is the most simple to use a boolean in table1

Than you read the table 1 where notmadetable2 = false.

You have to update table 1 than of course as well.

Probably is this not possible for you, however I start with the most simple
solution.

Cor
Nov 21 '05 #2
Geoff,

Is it a SQL database? If not you may be able to modify the statement below
to work for whatever database. I assume there is a key that links Table1 to
Table2, if so you could run some SQL as below.

Hope it helps.
Chris.

INSERT INTO Table2
(T2_Key
, T2_Field_1
, T2_Field_2
, T2_Field_3)
SELECT T1_Key
, T1_Field_1
, T1_Field_2
, T1_Field_3
FROM Table1
LEFT JOIN Table2 ON T2_Key = T1_Key
WHERE T2_Key IS NULL
"Geoff Jones" wrote:
Hiya

I have a problem which I'm working on which I hope someone can help with. I
have two tables in a database. For the sake of argument, let us call them
Table1 and Table2.

For each record in Table1, I want to write a record in Table2 where the
record will be made up of information from the corresponding record in
Table1.

If the application is shutdown and additional records are added to Table1,
the next time the application is run, I want to add extra records to Table2
from these "new" records; preferbly by not completely re-writing Table2 i.e.
appending new records to its end.

Obviously, the application will need to able to "know" which are the new
records.

Can anybody help with this? Some example code would be most appreciated.

Thanks in advance

Geoff

Nov 21 '05 #3
Thanks Cris and Cor. Most useful suggestions.

Geoff

"Chris Podmore" <Ch**********@discussions.microsoft.com> wrote in message
news:3F**********************************@microsof t.com...
Geoff,

Is it a SQL database? If not you may be able to modify the statement below
to work for whatever database. I assume there is a key that links Table1
to
Table2, if so you could run some SQL as below.

Hope it helps.
Chris.

INSERT INTO Table2
(T2_Key
, T2_Field_1
, T2_Field_2
, T2_Field_3)
SELECT T1_Key
, T1_Field_1
, T1_Field_2
, T1_Field_3
FROM Table1
LEFT JOIN Table2 ON T2_Key = T1_Key
WHERE T2_Key IS NULL
"Geoff Jones" wrote:
Hiya

I have a problem which I'm working on which I hope someone can help with.
I
have two tables in a database. For the sake of argument, let us call them
Table1 and Table2.

For each record in Table1, I want to write a record in Table2 where the
record will be made up of information from the corresponding record in
Table1.

If the application is shutdown and additional records are added to
Table1,
the next time the application is run, I want to add extra records to
Table2
from these "new" records; preferbly by not completely re-writing Table2
i.e.
appending new records to its end.

Obviously, the application will need to able to "know" which are the new
records.

Can anybody help with this? Some example code would be most appreciated.

Thanks in advance

Geoff

Nov 21 '05 #4
Following on from Chris's answer, if you are working with a SQL Server
database, then perhaps it would be worthwhile writing a trigger to let the
database automatically replicate the data to the second table.
--
Pete Wright
Author of ADO.NET Novice to Pro for Apress
www.petewright.org

"Chris Podmore" <Ch**********@discussions.microsoft.com> wrote in message
news:3F**********************************@microsof t.com...
Geoff,

Is it a SQL database? If not you may be able to modify the statement below
to work for whatever database. I assume there is a key that links Table1
to
Table2, if so you could run some SQL as below.

Hope it helps.
Chris.

INSERT INTO Table2
(T2_Key
, T2_Field_1
, T2_Field_2
, T2_Field_3)
SELECT T1_Key
, T1_Field_1
, T1_Field_2
, T1_Field_3
FROM Table1
LEFT JOIN Table2 ON T2_Key = T1_Key
WHERE T2_Key IS NULL
"Geoff Jones" wrote:
Hiya

I have a problem which I'm working on which I hope someone can help with.
I
have two tables in a database. For the sake of argument, let us call them
Table1 and Table2.

For each record in Table1, I want to write a record in Table2 where the
record will be made up of information from the corresponding record in
Table1.

If the application is shutdown and additional records are added to
Table1,
the next time the application is run, I want to add extra records to
Table2
from these "new" records; preferbly by not completely re-writing Table2
i.e.
appending new records to its end.

Obviously, the application will need to able to "know" which are the new
records.

Can anybody help with this? Some example code would be most appreciated.

Thanks in advance

Geoff

Nov 21 '05 #5

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

Similar topics

44
by: Mariusz Jedrzejewski | last post by:
Hi, I'll be very grateful if somebody can explain me why my Opera 7.23 (runing under linux) doesn't show me inner tables. Using below code I can see only "inner table 1". There is no problem with...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
2
by: Jill Elaine | last post by:
I am building an Access 2002 frontend with linked tables to an encrypted Paradox 7 database. When I first create these linked tables, I'm asked for the password to the encrypted Paradox database,...
1
by: Shelby | last post by:
Problem: My company generates its own data export from a propietary database. These (free) tables can be read in C#.NET using a Visual FoxPro driver (vfpoledb). I can read each of the six tables...
59
by: phil-news-nospam | last post by:
In followups by Brian O'Connor (ironcorona) to other posts, he repeats the idea that using tables in CSS is not something that should be done because IE doesn't support it. Of course I'm not happy...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
4
by: db2admin | last post by:
Hello, I want to plan rearranging tables in our database according to business areas. say all tables in business area A will be in seperate tablespace or tablespaces. I am planning to monitor...
25
by: bubbles | last post by:
Using Access 2003 front-end, with SQL Server 2005 backend. I need to make the front-end application automatically refresh the linked SQL Server tables. New tables will be added dynamically in...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.