我的陈述是否正确
$uid=1;
$pby=1;
$db->query("SELECT
CASE WHEN (c.uid!='$uid' and c.uid!='$pby')
THEN
( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM
comments c join users u on c.uid=u.uid where c.msgid='$id' and
c.condition!='ga' order by c.tstamp desc limit 10)
)
ELSE
( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM
comments c join users u on c.uid=u.uid where c.msgid='$id'
order by c.tstamp desc limit 10)
)
END
FROM comments c where c.msg_id='$id'") ;
我试过了,但结果是空的。不知道怎么了
更新到
选择 c.id、c.comment、c.uid、c.msgid、c.tstamp、u.fullname、u.img
CASE WHEN (c.uid!='$uid' and c.uid!='$pby')
THEN
( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM
comments c join users u on c.uid=u.uid where c.msgid='$id' and
c.condition!='ga' order by c.tstamp desc limit 10)
)
ELSE
( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM
comments c join users u on c.uid=u.uid where c.msgid='$id'
order by c.tstamp desc limit 10)
)
END
FROM comments c join users u on c.uid=u.uid where c.msgid='$id'