By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

Update table from other table

P: 10
Hello,

I have one table which I want to append it with new records, e.g. let's call this table TABLE1. The table from which I want to append is TABLE2. This table is made from queries, so it is always different.

table examples:

TABLE1:

ClientID |Date |Information|...
123 |1/1/11/ |abc
123 |2/1/11/ |def
456 |1/1/11/ |ref
456 |5/1/11 |abc
...

TABLE2:

ClientID |Date |Information|...
123 |1/1/11/ |abc
123 |2/1/11/ |def
123 |2/6/11/ |det

Is it possible to append/update TABLE1 with the information in TABLE2. I would like to have to primary keys: ClientID and Date. And I would like to update TABLE1 only with new information leaving old untouched. The new information is in bold in TABLE2. So the new table should look like this:

ClientID |Date |Information|...
123 |1/1/11/ |abc
123 |2/1/11/ |def
456 |1/1/11/ |ref
456 |5/1/11 |abc
123 |2/6/11/ |det

Can anyone tell how to do that?
Mar 20 '11 #1
Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,324
You could do an outer join and append those that don't exist in table1.
Mar 20 '11 #2

P: 10
Outer join doesnt help. Can You write the sql statement?
Mar 20 '11 #3

Rabbit
Expert Mod 10K+
P: 12,324
It is not standard procedure to give out code here. And outer join would work. You can use an outer join to determine records that don't exist in one of the joined tables.
Mar 20 '11 #4

NeoPa
Expert Mod 15k+
P: 31,271
Rolandas:
Outer join doesnt help. Can You write the sql statement?
This isn't too clear I'm afraid.
  1. If you mean the approach is wrong for any reason, then you should explain why you think that.
  2. If you are saying the response is not good enough for you, then you should go elsewhere for a while and learn some acceptable manners before returning.
We don't simply provide boilerplate solutions for our members here. We certainly don't expect any of our experts to deal with boorish behaviour.

I hope I've made my meaning clear.
Mar 22 '11 #5

P: 10
If it didnt help what could I say then?
I solved this question simply aplying append query. It helped because I used 2 primary keys.
Mar 22 '11 #6

NeoPa
Expert Mod 15k+
P: 31,271
Rolandas:
If it didnt help what could I say then?
Well, at the risk of repeating myself :
  1. If you mean the approach is wrong for any reason, then you should explain why you think that.
  2. If you are saying the response is not good enough for you, then you should go elsewhere for a while and learn some acceptable manners before returning.
It's really not complicated, and I've already answered the question before you asked it. I really struggle to understand why you would in the circumstances.
Mar 22 '11 #7

Post your reply

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