I have a query in which I am using a WHERE clause.
My QUERY:
SELECT * FROM notifications WHERE recipient= '".$_SESSION['id']."' AND viewed >
'".$twoweeksago."' OR viewed IS NULL ORDER BY recieved DESC
Basically, the query selects all rows of data where the recipient is the user logged in and viewed is a date less than two weeks old ($twoweeksago is a variable set in my script). But, the default for the viewed column is 0000-00-00 00:00:00 so I had to use:
OR viewed IS NULL
This creates a problem. I thought it was a condition only applied to the previous condition, which is:
AND viewed > '".$twoweeksago."'
But, it is actually an OR for the entire WHERE clause and voids all previous conditions. How can I write an OR condition that only affects AND viewed > '".$twoweeksago."'
Thanks!