tags:

views:

41

answers:

2

table 1(ob): name,address

table 2(address): dname,addr

I need to update ob.address with address.addr when ob.name=address.dname. Can anyone help to get better results because I'm using following command which leads system halt.

UPDATE ob LEFT JOIN address ON ob.name =address.dname SET ob.address=address.addr;

+2  A: 

This should do it:

update ob
set address = address_table.addr
where ob.name = address_table.dname

EDIT: Advice: use a better name for Table 2 than address. Maybe TBL_ADDRESS? In my above example I used address_table.

waqasahmed
should be address.addr instead of table2.address (more distinct naming would help the OP a lot here).
Lance Roberts
yes, only just noticed the poor naming conventions used for the tables and fields in the question :). Amended.
waqasahmed
A: 
UPDATE ob
SET ob.address = address.addr
WHERE ob.name = address.dname
Alex Martelli