Mysql查询并删除符合条件的子集

1周前 (2016-05-27)     作者:LG     分类:Mysql     阅读次数:     评论(0)    文章页统计代码
DELETE FROM purchase_suppliers_contract_materials_source
WHERE PSCMS_ID in(
	SELECT PSCMS_ID FROM(
		SELECT
			p1.PSCMS_ID
		FROM
			purchase_suppliers_contract_materials_source AS p1
		LEFT JOIN materials AS m ON p1.PSCMS_MATERIALS_ID = m.MATERIALS_ID
		LEFT JOIN (
			SELECT
				*
			FROM
				purchase_suppliers_contract_materials_source
		) AS p2 ON p1.PSCMS_PSC_ID = p2.PSCMS_PSC_ID
		AND p1.PSCMS_MATERIALS_ID = p2.PSCMS_MATERIALS_ID
		WHERE MATERIALS_ID is NULL) AS x
)
除非注明,发表在“石马人山的博客”的文章『Mysql查询并删除符合条件的子集』版权归LG所有。 转载请注明出处为“本文转载于『石马人山的博客』原地址http://longlonggo.com/html/1///150/155/311.html
文章页分享代码