Just got my February SQL Magazine and on page 26 there is something like this, without running the code try to figure out what the results are for the 3 selects
I actually had this problem once in 2001 and it took me a while to debug it
Denis The SQL Menace
SQL blog:
Personal Blog:
I actually had this problem once in 2001 and it took me a while to debug it
Code:
create table #customers (custid char(1) not null)
insert into #customers
select 'a' union all
select 'b' union all
select 'c'
create table #orders (ordercustid char(1) not null,id int not null)
insert into #orders
select 'a',1 union all
select 'b',1 union all
select 'a',2 union all
select 'b' ,2
select * from #customers where custid in(select custid from #orders) --How many rows?
Denis The SQL Menace
SQL blog:
Personal Blog: