Chartjs-Incorrect chart displayed using chart js

0👍

I suspect the problem is with your query.

$sql = "SELECT employee.FirstName, count(*) as TotalGroups from groupdetails, employee WHERE groupdetails.EmpId=employee.EmpId group by groupdetails.EmpId";

In the above, you’re using WHERE to specify a link between two tables. This is a job for JOIN. You also need to specify something concrete in WHERE unless you want to get all the rows.

$SQL = "SELECT employee.FirstName, count(*) as 'TotalGroups' FROM groupdetails g JOIN employee e ON g.EmpId = e.EmpId

If you need to use a WHERE in there to exclude some data, you’ll need to specify the table. For example, WHERE g.id = 5 to return ID 5 from the groupdetails table.

If you do want to return all rows, omit the WHERE clause altogether.

Leave a comment