I have an sql query:
SELECT A.Emp_ID, A.Emp_Name FROM Employee A INNER JOIN Assignment B on A.Emp_ID = B.Emp_ID WHERE B.Emp_ID HAVING COUNT(*) > 1;
Which returned the error:
SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group by Emp_ID' at line 1
So, I looked it up and found a post on here that talked about it, and what to do. So, I changed it to this:
SELECT A.Emp_ID, A.Emp_Name FROM Employee A INNER JOIN Assignment B on A.Emp_ID = B.Emp_ID WHERE B.Emp_ID HAVING COUNT(*) > 1 GROUP BY Emp_ID;
Which, to me, looks exactly like it is supposed to, so I'm confused why it doesn't work. Can someone help me straighten this out please? Thank you.
https://stackoverflow.com/questions/67040822/how-do-you-fix-the-group-by-requirement-in-sql-queries April 11, 2021 at 10:03AM
没有评论:
发表评论