$result="SELECT u.username, u.picture, m.id, m.user_note, m.reply_id, m.reply_name, m. m.dt
FROM relationships r, notes m, user u
WHERE m.user_id = r.leader
AND r.leader = u.user_id
AND r.listener ='".$_SESSION['user_id']."'
UNION
SELECT username, picture, id, user_note, reply_id, reply_name, dt
FROM user u, notes b
WHERE u.user_id = b.user_id
AND b.user_id = '".$_SESSION['user_id']."'
AND dt < '".$lastmsg."'
ORDER BY dt DESC
LIMIT 10 ";
我试图从这个超过'$ lastmsg'的查询中找到行而不是$ lastmsg本身,我想到使用少于但不等于运算符!我不确定那是不是很蠢!!!
P.S查询有效,但其重新发送的错误信息!!
答案 0 :(得分:0)
查看日期的查询片段不应该是
AND dt > '".$lastmsg."'
答案 1 :(得分:0)
您只限制UNION后半部分的日期。试试这个:
SELECT u.username, u.picture, m.id, m.user_note, m.reply_id, m.reply_name, m.dt
FROM relationships r, notes m, user u
WHERE m.user_id = r.leader
AND r.leader = u.user_id
AND r.listener ='".$_SESSION['user_id']."'
AND m.dt < '".$lastmsg."'
UNION
SELECT username, picture, id, user_note, reply_id, reply_name, dt
FROM user u, notes b
WHERE u.user_id = b.user_id
AND b.user_id = '".$_SESSION['user_id']."'
AND dt < '".$lastmsg."'
ORDER BY dt DESC
LIMIT 10