Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

 Want to do something like this:

SELECT * 

  FROM db.table 

 WHERE COUNT(someField) > 1

How can I achieve this in MySql?

1 Answer

0 votes
by (40.7k points)

Use the HAVING, not WHERE clause, for aggregate result comparison.

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...

Related questions

0 votes
2 answers
0 votes
2 answers
asked Jul 22, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...