I have a table that have tasks that have a “duedate” (to be completed by) column and a comp_status column. it also has a user id column
0 = uncomplete
1= complete
I want to do a query that shows tasks that dont have duedate of today but a duedate in the future and that have a comp_status = 0, I also want to show tasks that have a duedate of ‘0000-00-00’
$query = mysql_query("select * from taskdetail where userid='" . $rec['id'] . "' and comp_status='0' and duedate > '" . date("Y-m-d") . "' or duedate = '0000-00-00' order by duedate,importantlevel ASC");
For some reason some tasks that have a completed status are still showing?
Can you help?
The problem is the you have an OR in your statement: or duedate = ‘0000-00-00’ … because of this, any record that has this quality will show up. You need to group it with your other condition regarding the duedate, like so:
Note the parenthesis ()