July 10, 2006 at 5:17 pm
Can someone explain the results of this to me.
select count(*) from table1 where column1 in (select column1 from table2)
In this case table2 does not have a column called column1.
I would expect the result to be 0 or an error, column does not exist.
What I found was that it returned the full result set of table1.
Thanks for your help
July 10, 2006 at 5:26 pm
Not having done any testing, I suspect the reason why is the same as what is discussed here:
http://sqlservercode.blogspot.com/2006/06/delete-and-subquery-in-problem.html
July 11, 2006 at 3:48 pm
Thanks for the link and moving forward I will use the ANSI standard
DELETE T1
FROM Table1 T1
JOIN Table2 T2 ON T1.ID = T2.ID
Just out of curiosity do people consider this a bug in the count() function or is there a reason behind it working the way it does?
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy