开发者

SQL Inner Join Returns WAY More Rows Than Expected

The following query returns >7000 rows when each table on开发者_StackOverflow中文版ly has 340 rows.

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

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.


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.


Are the Spec field values non unique? This might explain why the query returns too many results; with duplicates you get get an effective cross product for those.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜