mysql update select

根据文件名 更新外键ID

UPDATE tb_obj  INNER JOIN tb_img ON tb_img.filename=tb_obj.filename  SET tb_objinfo.imgid = tb_imginfo.id;

关联删除

DELETE tb_sce FROM tb_sce,tb_img WHERE tb_sce.imgid=tb_img.id and tb_img.refurl is NULL;

 

同表select in 删除

DELETE FROM tb_img WHERE id IN ( SELECT * from ( SELECT id   FROM tb_img GROUP BY inum HAVING COUNT(inum)>1 ORDER BY inum) a);

posted @ 2017-02-03 17:02  ahuo  阅读(397)  评论(0编辑  收藏  举报