选择所有列时SQL区别

时间:2014-07-30 14:55:46

标签: mysql sql

我试过谷歌搜索但找不到任何东西。当我运行下面的查询时,它输出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') )

1 个答案:

答案 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)