delete from myTable
where id not in
(select min(id)
from myTable
group by A, B)
i.e. the select in brackets returns the first id for each grouping of A and B; deleting all ids that are not in this set will remove all occurences of an A-plus-B combination that are "subsequent" to its first occurrence.
EDIT: this syntax seems to be problematic: see bug report:
http://bugs.mysql.com/bug.php?id=5037
A possible workaround is to do this:
delete from myTable
where id not in
(
select minid from
(select min(id) as minid from myTable group by A, B) as newtable
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…