一个字段值为条件查询另一张表值

发布时间:2017-07-27 13:35:31编辑:丝画阁阅读(216)

SELECT ys.id,ys.productname,ys.dirname,ysb.dirname AS bdirname,ysb.nickname,ysb.productname,ysb.salesnum FROM yzj_singlelist ys,  yzj_singlelistbak ysb  WHERE   ys.productname LIKE CONCAT('%',ysb.nickname,'%') AND ysb.nickname !="" AND ysb.dirname=""  ORDER BY ysb.salesnum DESC;


UPDATE yzj_singlelist ys JOIN yzj_singlelistbak ysb ON  ys.dirname=ysb.dirname SET ys.salesnum =ysb.salesnum;

关键字