im trying to select distinct, the column 'content' in my table reviews,
it works when i do this:
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;
}
but i also need columns
r.from_user_id, p.display_name, r.id reviews_id, r.date_added
and when i try and add them in it has lots of the same content going down the page, is there a way i can just select all fields in my table but only distinct select the content column?
thanks
GROUP BY
that specific column?content
, say'thisvalue'
, there must be more than one set of values for the other columns (otherwise you wouldn't observe the behaviour you describe). Therefore, which of those multiple possible values do you wish to select for each distinct value ofcontent
?