日期:2014-05-16 浏览次数:20610 次
?如何删除表中相同的记录(比如相同的id,假设没有主键)
--方法1?
DELETE FROM EMP
WHERE ROWID NOT IN(SELECT MAX(ROWID) FROM EMP GROUP BY EMPNO)
--方法2
DELETE FROM emp e
WHERE ROWID NOT IN ( SELECT MIN(ROWID) FROM emp a
WHERE e.empno=a.empno);
--方法3
DELETE FROM table_name A
WHERE ROWID > ( SELECT min(ROWID) FROM table_name B WHERE A.col = B.col);