This is my MySql table
----------- --------------
location_id location_name
----------- --------------
1 office
2 hospital
3 schools
I am running INSERT INTO query based on the location_id.
what i want is - if location id exists, return some message. else run INSERT query.
My Query
$sql = "SELECT location_id FROM tablename GROUP BY location_id HAVING count(*) > 1";
$rs=parent::_executeQuery($sql);
$rs = parent::getAll($rs);
if($rs)
{
//RUN INSERT QUERY
}
else
{
//RETURN SOME MESSAGE
}
Well, this is going inside if block everytime.