我试过谷歌搜索但找不到任何东西。当我运行下面的查询时,它输出4个相同的行。所以我想使用DISTINCT关键字来消除重复。但是当我运行查询时出现SQL错误。删除DISTINCT,它工作正常。
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') )
答案 0 :(得分:1)
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)