$result = mysql_query("SELECT * FROM users_msgs WHERE uID = '$USER' AND date<'$lastmsg' AND date BETWEEN $Yday AND $today ORDER by date DESC LIMIT 10");
Im getting 0 rows while there should be 1..
But my other query,
$result = mysql_query("SELECT * FROM users_msgs WHERE uID = '$USER' AND date > $today
AND date<'$lastmsg'
ORDER by date DESC LIMIT 10");
works fine, and also filters the same column twice?
So what is the problem my first query?
The two queries are using different criteria to filter on the
datecolumn.Both require
dateto be less than$lastmsg, but the first query (which you said doesn’t work) requiresdateto also be greater than or equal to$Ydayor less than or equal to$today. The second query requires thatdatebe greater than$today. The filtration is opposite of each other.There’s no issue with multiple filter criteria on a column — you just have to have the data to satisfy the requirements in order to get results.