我使用DISTINCT
子句进行了以下查询,但结果仍显示重复的ID&#39>:
SELECT DISTINCT
rl.countryid, rl.resellerid, c.countryname, c.iso2, r.resellerid
FROM reseller_locator rl
INNER JOIN countries c
ON rl.countryid = c.countryid
LEFT JOIN resellers r
ON r.parentid = 7
WHERE
rl.resellerid = 7
OR rl.resellerid = r.resellerid
答案 0 :(得分:5)
DISTINCT
与指定的所有列有关,因此,如果您有2个记录具有相同的countryid
但不同的resellerid
,两者都将显示。