PHP MySQL查询具有独特性和LIMIT

时间:2014-08-30 04:19:39

标签: php mysql sql

我需要使用SELECT DISTINCT对我的PHP MySQL查询提出建议。数据结果显示为我想要的。但是现在面临问题,数据显示不是显示5行。有时6行,有时4等等。

请帮忙!有没有办法在下面查询我的代码:

$q = mysql_query("SELECT * FROM tb_post WHERE uid = '$uid' LIMIT 5");
while($d_check = mysql_fetch_array($q))
{
$q2 = mysql_query("
    SELECT DISTINCT C.uid_fk, C.msg_id_fk, C.comment, C.created, U.username, U.uid, U.full_name, U.avatar
    FROM tb_comment C, tb_user U
    WHERE C.uid_fk = U.uid AND C.msg_id_fk = '$get_post_id'
    AND C.uid_fk != '$uid' ORDER BY C.created LIMIT 5");
}

0 个答案:

没有答案