Possible Duplicate:
SQL Delete: can't specify target table for update in FROM clause
I have one table only (call this table TAB), representing University exams. I have the following attributes: CourseName, CourseCode and year. I want to delete all courses that have a cardinality less than 100. If I type
select CourseName from TAB group by CourseName having count(CourseName) < 100;
I have an exact result. But if I want to delete this entries I try with
delete from TAB where CourseName not in (select CourseName from TAB group by CourseName having count(CourseName) > 100);
but the system returns an error:
Error Code: 1093 You can't specify target table 'TAB' for update in FROM clause
How I have to delete these records?