开发者

Why does the number of rows increase in a SELECT statement with INNER JOIN when a second column is selected?

I am writing some queries with self-joins in SQL Server. When I have only one col开发者_开发问答umn in the SELECT clause, the query returns a certain number of rows. When I add another column, from the second instance of the table, to the SELECT clause, the results increase by 1000 rows!

How is this possible?

Thanks.

EDIT:

I have a subquery in the FROM clause, which is also a self-join on the same table.


How is this possible?

the only thing I can think of is that you have SELECT DISTINCT and the additional column makes some results distinct that weren't before the additional column.

For example I would expect the second result to have many more rows

SELECT DISTINCT First_name From Table

vs

SELECT DISTINCT First_name, Last_name From Table

But if we had the actual SQL then something else might come to mind

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜