Bug #2393 NOT IN subquery cause main query returns no result
Submitted: 14 Jan 2004 21:00 Modified: 16 Mar 2004 6:09
Reporter: David Yao
Status: Closed
Category:Server Severity:S1 (Critical)
Version:4.1.1 OS:Microsoft Windows (Windows XP)
Assigned to: Oleksandr Byelkin Target Version:

[14 Jan 2004 21:00] David Yao
Description:
When using subquery to restrict the main query result, if using in(.....) returns the
right result, but when using NOT IN (....) if the subquery results more then a couple of
rows, the main query returns no result.

How to repeat:
create table test_table 
(id int not null primary key, text varchar(20) not null default '');

insert into test_table (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4,
'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10,
'text10'), (11, 'text11'), (12, 'text12'); 

/*
the query below shoud return 7 rows, however, it returns nothing
*/

select * from test_table where id not in (select id from test_table where id < 8);
[15 Jan 2004 13:29] Dean Ellis
Verified against 4.1.2/Linux.  Thank you.
[1 Feb 2004 17:43] Oleksandr Byelkin
ChangeSet 
  1.1688 04/02/02 02:23:53 bell@sanja.is.com.ua +4 -0 
  avoid null check on fields where NULL is impossible 
  (BUG#2393)
[16 Mar 2004 6:09] Oleksandr Byelkin
Thank you for bug report.  
 
This bug is fixed in our internal repository => fix will be present in next 
server release.
[9 May 2008 12:06] max williams
I'm still seeing this bug in mysql version = 5.0.45-Debian_1ubuntu3.3-log
[10 May 2008 2:02] Sergey Petrunya
Not repeatable on 5.0.51a on mysql-5.0.51a-linux-i686.tar.gz official binary.