I want to do something like this:
SELECT * FROM db.table WHERE COUNT(someField) > 1
How can I achieve this in MySql?
Use the HAVING, not WHERE clause, for aggregate result comparison.
HAVING
WHERE
Taking the query at face value:
SELECT * FROM db.table HAVING COUNT(someField) > 1
Ideally, there should be a GROUP BY defined for proper valuation in the HAVING clause, but MySQL does allow hidden columns from the GROUP BY...
GROUP BY
Is this in preparation for a unique constraint on someField? Looks like it should be...
someField
2.1m questions
2.1m answers
60 comments
57.0k users