Welcome Guest, Not a member yet? Register   Sign In
trouble with SQL bindings
#1

(This post was last modified: 11-11-2020, 06:55 PM by richb201.)

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
Reply


Messages In This Thread
trouble with SQL bindings - by richb201 - 11-11-2020, 06:44 PM
RE: trouble with SQL bindings - by ojmichael - 11-12-2020, 12:21 AM
RE: trouble with SQL bindings - by richb201 - 11-12-2020, 12:40 AM
RE: trouble with SQL bindings - by ojmichael - 11-12-2020, 04:24 PM
RE: trouble with SQL bindings - by richb201 - 11-13-2020, 01:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB