gpt4 book ai didi

即使使用 Distinct,MySQL 也会多次返回相同的结果

转载 作者:行者123 更新时间:2023-11-29 13:35:12 25 4
gpt4 key购买 nike

这里是sql

        SELECT DISTINCT
t1.`name` team1_name,
t1.id team1_id,
t2.id team2_id,
t2.`name` team2_name,
sc.`name_en` sportCatname,
c.title championshipTitle,
e.date eventDate,
e.id eventId,
e.title,
FROM
`Event` e,
`SportCategory` sc,
`Championship` c,
`Team` t1,
`Team` t2
WHERE
e.top = 1
AND t1.id = e.team1ID
AND t2.id = e.team2ID
AND sc.id = c.sportCategoryID

也尝试过加入。决不。它返回正确的行,但是在结果集中我有两次相同的行。我做错了什么?

最佳答案

where 子句中的 SportCategoryChampionship 没有关系。这就是产生重复结果的原因。

您应该在 where 子句中提供关系。

关于即使使用 Distinct,MySQL 也会多次返回相同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18842671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com