Not sure how to do it in a single query, but if you run this query repeatedly, 
eventually you'll have only 10 left of each category.

DELETE tableName
FROM tableName, (SELECT MAX(ID) deleteID,count(ID) categCount FROM tableName GROUP BY Category HAVING categCount>10) AS Smry WHERE tableName.ID=Smry.deleteID


----- Original Message ----- From: "abhishek jain" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Sunday, April 08, 2007 7:26 AM
Subject: Query needed for this sol.


Hi all,
I need a query for the fol. sol.
In a table i have 100s of rows with six categories like A,B,C,D,E,F which is
marked with a column like
Table
ID Category
1   A
2   A
3  B
4   B
5  B
6 C
7 C

and so on 100 ids for each of six categories , i want to delete all but 10
ids of each category, i wanted to know how to do so,

Pl. help
Thanks,
Abhishek jain



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to