Home » Developer & Programmer » Forms » How to write this sql?
How to write this sql? [message #80682] Thu, 31 October 2002 06:53 Go to next message
Fico
Messages: 26
Registered: July 2002
Junior Member
Table1:

ID,Field1,field2
1,aaaa1,bbbb1
2,aaaa2,bbbb2
3,aaaa3,bbbb3

Table2:
ID,Field1,Field2
2,xxxxx,yyyyy
3,zzzzz,sssss

How to update table1 with table2 , if ID not match then keep old value.

after update:
Table1:
1,aaaa1,bbbb1
2,xxxxx,yyyyy
3,zzzzz,sssss

Can I do this?
update table1 a
set (field1,field2)=
(
select b.field1,b.field2
from table2 b
where a.id=b.id
)
Run this sql,Table1 record 1 value is null.

Thanks.
Re: How to write this sql? [message #80685 is a reply to message #80682] Thu, 31 October 2002 17:04 Go to previous message
Julie
Messages: 98
Registered: February 2002
Member
add:
and exists (select * from table2 c where c.id = a.id)
Previous Topic: Any Help Pls, Its Urgent
Next Topic: Re: what is the full form of srw (package found in report builder)
Goto Forum:
  


Current Time: Sat Mar 02 20:05:10 CST 2024