gmc1103 Posted October 8, 2015 Share Posted October 8, 2015 Hi I would like some help with this query, the purpose is when someone make an activity , after the date he must define if that activity has been done or not, and i want to put an alert until those fields are registered into the database The query is this one SELECT COUNT( * ) AS total FROM `nem_pae_atividades` WHERE `idutilizador` =1355 AND `data` >= CURDATE( ) AND `realizado` IS NULL OR LENGTH( `realizado` ) =0 But i have always 1 because of the last "and", how can i fix this?? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 8, 2015 Share Posted October 8, 2015 When mixing AND and OR always use ( )'s to define your logic. For example A AND B OR C Do you mean (A AND B) OR C or A AND (B OR C) Quote Link to comment Share on other sites More sharing options...
gmc1103 Posted October 8, 2015 Author Share Posted October 8, 2015 Hi Barand Thank you, iv'e tried the way you told me with no success This is what i have in my db So my point is the make the owner change the field "realizado" if the "data" has been reached My last query was SELECT COUNT( * ) AS total FROM `nem_pae_atividades` WHERE ( `idutilizador` =1355 AND `data` >= CURDATE( ) ) OR ( `realizado` IS NULL OR LENGTH( `realizado` ) ) =0 Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted October 8, 2015 Solution Share Posted October 8, 2015 try SELECT COUNT( * ) AS total FROM `nem_pae_atividades` WHERE `idutilizador` =1355 AND `data` <= CURDATE( ) AND ( `realizado` IS NULL OR LENGTH( `realizado` )=0 ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.