Jump to content

Help adding DISTINCT to query


slj90

Recommended Posts

I need to add likes_username to this query and use a DISTINCT on it.

 

It currently counts how many likes a status has but in the table there are some statuses with multiple likes from the same username. 

SELECT s.*, COUNT(l.likes_location_id) AS likeCount
 FROM stream AS s
  LEFT JOIN likes AS l ON ( l.likes_location_id = s.stream_id )
 GROUP BY s.stream_id
 ORDER BY s.stream_id DESC LIMIT 50

Many thanks,

 

Link to comment
https://forums.phpfreaks.com/topic/293316-help-adding-distinct-to-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.