我试图选择不同的,我的表评论中的列'内容',
当我这样做时它会起作用:
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
当我尝试添加它们时,页面上有很多相同的内容,有没有办法我可以选择表格中的所有字段,但只选择不同的内容列?
感谢
答案 0 :(得分: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