sql查询更新

CREATE TABLE `A` (
  `EQONAME` varchar(100) collate utf8_bin default NULL,
  `EQSORT` varchar(40) collate utf8_bin default NULL,
  `EQSUM` decimal(32,0) default NULL,
  `OCODE` varchar(40) collate utf8_bin default NULL
)
CREATE TABLE `B` (
  `ONAME` varchar(100) collate utf8_bin default NULL,
  `OCODE` varchar(23) character set utf8 default NULL
)

UPDATE A
SET EQONAME = (
SELECT ONAME FROM B b
WHERE A.OCODE LIKE b.OCODE
)

来源:
http://xialiang19851204.blog.163.com/blog/static/3720773520105225405187/

你可能感兴趣的:(sql,Blog)