You can join the table from a subquery that returns only a unique foo using LEFT JOIN . Rows that do not have a match in the subquery will be deleted as you wish, for example
DELETE a FROM TableName a LEFT JOIN ( SELECT foo FROM TableName GROUP BY Foo HAVING COUNT(*) = 1 ) b ON a.Foo = b.Foo WHERE b.Foo IS NULL
For better performance, add an index to the foo column.
ALTER TABLE tableName ADD INDEX(foo)
John woo
source share