UPDATE machine m JOIN ( SELECT js.ID,CONCAT(jxl.JXLMC,js.SSLC,'层',js.JSMC) as JSQC FROM gongxin_jw_jxljs as js JOIN (SELECT ID,JXLMC FROM gongxin_jw_jxljs WHERE FATHER_ID = 0) as jxl on jxl.ID = js.FATHER_ID WHERE js.FATHER_ID <> 0 ) as jsON m.MEMO = js.JSQCSET m.roomid = js.ID一个要对接的系统,本来两张表的事情,硬是塞进一张表,于是就搞出来了这么复杂的更新sql。依次留念,时时告诫自己。数据库的表也要简单话,避免一张表承担过多的责任。