Mysql Update Query is not Giving Desired Result

MySQLPHP

In My Php Code I Have Query As

SELECT COUNT(id) AS todayleads 
FROM `lead_data` 
where `date` = '$todate' AND lead_status = 1 
AND uid = '$userid' OR assign_to = '$userid'

When I echo Query it result me

SELECT COUNT(id) AS todayleads
FROM `lead_data` 
where `date` = '2018-01-12' AND lead_status = 1 
AND uid = '3' OR assign_to = '3'

And Output Gives Mea All Data From Start to End. But Expected O/p is Only Data That have lead_status = 1 and uid = 3 Or assign_to = 3.

Best Answer

As far as I understand according to your comments you should add a parentheses to your WHERE clause:

SELECT COUNT(id) AS todayleads
FROM   `lead_data` 
WHERE  `date` = '2018-01-12' 
AND    lead_status = 1 
AND    (uid = '3' OR assign_to = '3')