Reputation: 1568
I've tried Googling this but couldn't find anything. When I run the query below, it outputs 4 identical rows. So I want to use the DISTINCT keyword to eliminate the duplicates. But I get an SQL error when I run the query. Remove the DISTINCT and it works fine.
SELECT DISTINCT list.`id`, *
FROM `listings` list
INNER JOIN `selections` sel
ON list.`id` = sel.`lid`
WHERE 1 AND `activity` = 'running'
AND ( 0 OR (sel.`parent` =
'1') OR (sel.`parent` = '2') )
Upvotes: 0
Views: 265
Reputation: 33945
SELECT DISTINCT columns.you
, actually.want
FROM listings l
JOIN selections s
ON l.id = s.lid
WHERE activity = 'running'
AND s.parent IN(1,2)
Upvotes: 1