Welcome Guest, Not a member yet? Register   Sign In
Having a problem with Count(*)
#1

[eluser]afro[/eluser]
Hi people, can anyone help me out with this, am trying to restrict the no
of people from the same department to go on leave at the same time.

Thanks.

Code:
function check_staff_on_leave()
   {
                
$query = "SELECT Department, COUNT(*) as 'On Leave'
    FROM checkoff
    WHERE Department = '".$this->input->post('department')."'
    GROUP BY Department
    HAVING COUNT(*) > 3";
    $this->db->query($query);
    $q = $this->db->get();
    return $q->num_rows();
    if($query->num_rows() > 3)
    {
    return false;
    }
    else
    {
    $query->free_result();
    return true;
    }
            
}

Am getting this error
Error Number: 1096

No tables used

SELECT *


Messages In This Thread
Having a problem with Count(*) - by El Forum - 03-29-2011, 01:35 AM
Having a problem with Count(*) - by El Forum - 03-29-2011, 01:41 AM
Having a problem with Count(*) - by El Forum - 03-29-2011, 01:57 AM
Having a problem with Count(*) - by El Forum - 03-29-2011, 03:18 AM
Having a problem with Count(*) - by El Forum - 03-29-2011, 03:53 AM
Having a problem with Count(*) - by El Forum - 03-30-2011, 03:55 AM
Having a problem with Count(*) - by El Forum - 03-30-2011, 04:07 AM
Having a problem with Count(*) - by El Forum - 03-30-2011, 05:40 AM
Having a problem with Count(*) - by El Forum - 03-30-2011, 06:18 AM
Having a problem with Count(*) - by El Forum - 03-30-2011, 06:35 AM
Having a problem with Count(*) - by El Forum - 03-31-2011, 02:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB