gpt4 book ai didi

mysql:在表中选择不同的列?

转载 作者:行者123 更新时间:2023-11-29 03:39:23 25 4
gpt4 key购买 nike

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

当我这样做时它有效:

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

当我尝试将它们添加到其中时,页面下方有很多相同的内容,有没有一种方法可以让我只选择表格中的所有字段,但只选择不同的内容列?

谢谢

最佳答案

我想这就是你要找的伙伴:

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

关于mysql:在表中选择不同的列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16317170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com