mysql删除重复数据(通过多个字段分组,删除某一字段为空的数据)

DELETE FROM t_questions
WHERE Id in (
    SELECT Id FROM (
        SELECT Id FROM `t_questions`
            WHERE (Name,QuestionTypeId) 
                in (SELECT Name,QuestionTypeId FROM `t_questions` GROUP BY Name,QuestionTypeId HAVING Count(*) > 1)
                    AND Id 
                    NOT in (SELECT Id FROM `t_questions` WHERE Intention IS NOT NULL)
                                ) as a
)

 

 
posted @ 2019-10-31 11:32  an_blog  阅读(368)  评论(0编辑  收藏