remove duplicates from sql union

后端 未结 6 571
北恋
北恋 2020-12-29 01:45

I\'m doing some basic sql on a few tables I have, using a union(rightly or wrongly)

but I need remove the duplicates. Any ideas?

select * from calls
         


        
6条回答
  •  醉酒成梦
    2020-12-29 02:22

    Since you are still getting duplicate using only UNION I would check that:

    • That they are exact duplicates. I mean, if you make a

      SELECT DISTINCT * FROM () AS subquery

      you do get fewer files?

    • That you don't have already the duplicates in the first part of the query (maybe generated by the left join). As I understand it UNION it will not add to the result set rows that are already on it, but it won't remove duplicates already present in the first data set.

提交回复
热议问题