SQL内部联接返回的行比预期多 [英] SQL Inner Join Returns WAY More Rows Than Expected

查看:64
本文介绍了SQL内部联接返回的行比预期多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当每个表只有340行时,以下查询将返回> 7000行.

The following query returns >7000 rows when each table only has 340 rows.

SELECT Config.Spec, TempTable.Spec FROM Confg INNER JOIN TempTable on Config.Spec = TempTable.Spec

为什么会这样?如果INNER JOIN仅在两个表中都有匹配项时才返回一行,那为什么还要为匹配项返回多行呢?

Why would this happen? If an INNER JOIN only returns a row if there is a match in both tables then why would it return multiple rows for a match.

推荐答案

如果TempTable中的Spec值与Confg中的Spec值相同,则存在多个行得到重复的行,反之亦然.

If there is more than one row with the same Spec value in TempTable for the same Spec value in Confg, then you will get duplicate rows, and vice versa.

这篇关于SQL内部联接返回的行比预期多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆