如何删除sql中的重复项

时间:2017-08-17 05:18:31

标签: sql

如何删除以下sql中的重复结果?

SELECT    * 
FROM      fccestimatedcustomer LEFT JOIN fcccustomerregistration 
ON        fccestimatedcustomer.CustomerRegistrationRefID = 
          fcccustomerregistration.CustomerRegistrationRefID
WHERE     fccestimatedcustomer.Status = 1 
ORDER BY  VehicleNumber ASC;

2 个答案:

答案 0 :(得分:1)

SELECT DISTINCT * 
FROM      fccestimatedcustomer LEFT JOIN fcccustomerregistration 
ON        fccestimatedcustomer.CustomerRegistrationRefID = 
          fcccustomerregistration.CustomerRegistrationRefID
WHERE     fccestimatedcustomer.Status = 1 
ORDER BY  VehicleNumber ASC;

试试这个。如果不行,请发布你的fccestimatedcustomer,fcccustomerregistration表的一些示例数据

答案 1 :(得分:0)

最简单的方法是将DISTINCT与您希望进行此选择的指定字段一起使用。