id若是字符型:update foretak set area_code=(select area_code from foretag_phone where id=foretak.company_id and id='100000005'); 若是数定型: update foretak set area_code=(select area_code from foretag_phone where id=foretak.company_id and id=100000005);
同志,你为什么不好好看 beckham 的回复?update foretak a set area_code = (select area_code from foretag_phone where id = a.company_id)
同志,我问问题之前肯定是经过测试的。 update foretak a set area_code = (select area_code from foretag_phone where id = a.company_id) 在oracle中根本就没有办法执行,我不知道你试过了没有?包括beckham的写法,也没有办法执行,可能是因为符合查询条件的记录不唯一,比如说: foretag_phone.id foretak.company_id 1 1 2 2 3 3 虽然ID 和 COMPANY_ID都是唯一的,但是对应的结果并不是唯一的。 曾经试过这样的更新: update foretak a set area_code = (select area_code from foretag_phone where id = a.company_id) WHERE a.company_id = 100000005 就是可以很快执行的,也是因为记录唯一。 不过,很谢谢你的帮助!!
若是数定型:
update foretak set area_code=(select area_code from foretag_phone where id=foretak.company_id and id=100000005);
...where(,,,,)
update foretak a set area_code = (select area_code from foretag_phone where id = a.company_id)
在oracle中根本就没有办法执行,我不知道你试过了没有?包括beckham的写法,也没有办法执行,可能是因为符合查询条件的记录不唯一,比如说:
foretag_phone.id foretak.company_id
1 1
2 2
3 3
虽然ID 和 COMPANY_ID都是唯一的,但是对应的结果并不是唯一的。
曾经试过这样的更新:
update foretak a set area_code = (select area_code from foretag_phone where id = a.company_id) WHERE a.company_id = 100000005 就是可以很快执行的,也是因为记录唯一。
不过,很谢谢你的帮助!!