delete a from 表 a left join(
select 主键=min(主键) from 表
group by 列1,列2 --假设对列1,列2去重复
)b on a.主键=b.主键
where b.主键 is null
select 主键=min(主键) from 表
group by 列1,列2 --假设对列1,列2去重复
)b on a.主键=b.主键
where b.主键 is null
调试欢乐多
你能这个语法:
delete a from 表 a left join(
select 主键=min(主键) from 表
group by 列1,列2 --假设对列1,列2去重复
)b on a.主键=b.主键
where b.主键 is null
我不是很懂,能麻烦你解释一下吗??谢谢啦
至于多表连接,只要吃透select,问题不会很大。而且,自己看可能比问要快。
例如,查询如果得到如下结果:
col1 col2 col3 col4
------- ------- ------ ---------
1 1 1 2
1 1 1 3
1 2 1 2
1 2 2 2
如果你想col1,col2列的值不重复,那么你必须确定col3,col4的值如何取舍(取那些值)