I have two versions of the same sql statement; one using bindings and one not using bindings. I am trying to get the results for each employee named in srat.employee. The one with the binding returns 116 rows. The one without the binding returns 4 rows. The second one without the bindings is correct, the answer should be four. I'd like to be able to run the query that returns 4 rows for each employee_email. How can I create a loop where I can run the query with bindings for each strat.employee_email?
//run with bindings
$sql = "SELECT srat.employee_email,srat.taxyear, sr.item, kt.qualified, kt.unqualified
FROM survey_results_activities_temp srat, survey_results sr, key_temp kt
WHERE sr.user_email=? AND sr.taxyear=? AND sr.item_type='AC' AND sr.item=kt.activity";
$query6=$this->db->query($sql, array($email,$taxyear));
//run without bindings
$sql = "SELECT srat.employee_email,srat.taxyear, sr.item, kt.qualified, kt.unqualified
FROM survey_results_activities_temp srat, survey_results sr, key_temp kt
WHERE sr.user_email=srat.employee_email AND sr.taxyear=srat.taxyear AND sr.item_type='AC' AND sr.item=kt.activity";
$query6 = $this->db->query($sql);
//here I total the qualified and unqualified for each employee
proof that an old dog can learn new tricks