Subject | Help with SQL |
---|---|
Author | Cao Ancoinc |
Post date | 2005-02-25T09:34:24Z |
Hi everyone
I would like to insert records from table B into Table A where
the record does not exist in Table A and mark the record in
table B as posted
eg
Table A Table B
Key ColA ColB ColC Key ColA ColB Posted
=== === ==== ==== === === ==== ======
A 1 11 111 B 2B 22B
B 2 22 222 D 4D 44D
C 3 33 333 E 5E 55E
Result
Table A Table B
Key ColA ColB ColC Key ColA ColB Posted
=== === ==== ==== === === ==== ======
A 1 11 111 B 2B 22B
B 2 22 222 D 4D 44D True
C 3 33 333 E 5E 55E True
D 4D 44D
E 5E 55E
I have used the following sql
Insert into TableA(Key, ColA,ColB)
Select TableB.Key,TableB.ColA, TableB.ColB from TableB
WHERE not exists (select * from TableA
where TableA.Key = TableB.Key);
How do I mark the record as posted in TableB using the same sql
I would appreciate any help from the gurus out there
Regards Cao
I would like to insert records from table B into Table A where
the record does not exist in Table A and mark the record in
table B as posted
eg
Table A Table B
Key ColA ColB ColC Key ColA ColB Posted
=== === ==== ==== === === ==== ======
A 1 11 111 B 2B 22B
B 2 22 222 D 4D 44D
C 3 33 333 E 5E 55E
Result
Table A Table B
Key ColA ColB ColC Key ColA ColB Posted
=== === ==== ==== === === ==== ======
A 1 11 111 B 2B 22B
B 2 22 222 D 4D 44D True
C 3 33 333 E 5E 55E True
D 4D 44D
E 5E 55E
I have used the following sql
Insert into TableA(Key, ColA,ColB)
Select TableB.Key,TableB.ColA, TableB.ColB from TableB
WHERE not exists (select * from TableA
where TableA.Key = TableB.Key);
How do I mark the record as posted in TableB using the same sql
I would appreciate any help from the gurus out there
Regards Cao