Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to solve errors in MySql subquery

I’m learning Mysql, a newbie.
First I wrote:

Select name, count(*)
From Emp
Group By name;

and the code was successful.
After that, I added to the code it became:

Select *
From Emp
Where (Select name, count(*)
From Emp
Group By name) > 1;

and I get an error message too many values.
How to fix that?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

To get all the information of the employees that have the same name, you can do folowing

Select e1.*
From Emp  e1 INNER JOIN (Select DISTINCT name
From Emp
Group By name
having count(name) > 1) e2 ON e2.name = e1,name
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading