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
1 answer
0 votes
1 answer
asked Jul 12, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Jul 22, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Dec 31, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer

31k questions

32.4k answers

500 comments

693 users

Browse Categories

...