2

我试图在我的表格评论中选择不同的“内容”列,

当我这样做时它有效:

function get_new_reviews() {
            global $connection;
            global $_SESSION;
            $query = "SELECT DISTINCT r.content
                        FROM ptb_reviews r, ptb_profiles p
                        WHERE r.to_user_id =".$_SESSION['user_id']."
                        AND r.deleted = '0'
                        AND r.read_review = '0'
                        AND r.approved = '0'
                        AND r.from_user_id != '0'
                        ORDER BY r.date_added DESC 
                        LIMIT 0, 14";


                        $reviews_set = mysql_query($query, $connection);
            confirm_query($reviews_set);
            return $reviews_set;
        } 

但我也需要专栏

r.from_user_id, p.display_name, r.id reviews_id, r.date_added

当我尝试添加它们时,页面上有很多相同的内容,有没有办法我可以选择表中的所有字段,但只能选择内容列?

谢谢

4

1 回答 1

0

我认为这就是您要寻找的伴侣:

SELECT *
FROM (
    SELECT r.content, r.from_user_id, p.display_name, r.id reviews_id, r.date_added
    FROM ptb_reviews r, ptb_profiles p
    WHERE r.to_user_id =".$_SESSION['user_id']."
        AND r.deleted = '0'
        AND r.read_review = '0'
        AND r.approved = '0'
        AND r.from_user_id != '0'
    GROUP BY r.content
    LIMIT 0, 14
) t1
ORDER BY date_added DESC 
于 2013-05-01T11:29:06.173 回答