Trying to get an INNER JOIN to work is driving me insane, so I’m very much hoping that someone can help me out here.
I have two tables in a database:
BranchEmployees
DepartmentEmployees
Both tables have a column called EmpID so I can track which employees are assigned to which department and to which branch. I’m making a report that finds which employees are assigned to a specified department and branch, excluding all the rest so an INNER JOIN query seems like the logical solution, but we just cannot get it to work. We keep getting the fatal error:
Fatal error: Call to a member function fetchAll() on a non-object in ...
$query="SELECT DepartmentEmployees.EmpID FROM DepartmentEmployees INNER JOIN BranchEmployees ON DepartmentEmployees.EmpID=BranchEmployees.EmpID";
$connect=$cdb->query($query);
$EmployeeList[$m]=$connect->fetchAll(PDO::FETCH_ASSOC);
Does it matter that it’s on a shared server when trying to INNER JOIN tables? I don’t think it should from what I can read, but you never know.
Just change this line for db connection, query should work;
I hope this helps.