关于sql:PHP:在查询中过滤两次相同的列

PHP: filter same column two times in query

1
$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");

我得到0行,而应该有1。

但我的另一个问题是,

1
2
3
 $result = mysql_query("SELECT * FROM users_msgs WHERE uID = '$USER' AND date > $today
AND date<'$lastmsg'
ORDER by date DESC LIMIT 10"
);

工作正常,还过滤同一列两次?

那么,我的第一个查询有什么问题?


二是利用标准的查询不同的茶dateon the column to filter。P></

daterequire to be less $lastmsg,but the first查询(which……你说的不好的工作date)也比前更大的平等$Ydayor less equal to or to $today。嗯……that the second查询date$today比更大。opposite of each other is the过滤。P></

没有问题,与标准的多滤波器在线柱- You have to just have to the日期要求以满足to get the results。P></


if the type of is日期或日期,日期时间timestamp(EN should be,如果它不是,那么你必须把你的)变量之间的简单的quotes:date BETWEEN '$Yday' AND '$today'P></

让你的变量值(contain the contain你认为他们。你也可以测试,如果你的查询返回mysql_query('...') or exit(mysql_error());安误差:P></