Subject Weird query results - bug?
Author Kjell Rilbe
Hi,

This SQL returns 2533 records, none of which contain B."Kod" starting
with 1711 or 2111 (checked thoroughly):
select B.*
from "Branschkod" B
inner join "Branschkod" B2 on B2."Namn" = B."Namn"
where B."ECO_ID" <> B2."ECO_ID"

Now, I add a line to the WHERE:
select B.*
from "Branschkod" B
inner join "Branschkod" B2 on B2."Namn" = B."Namn"
where B."ECO_ID" <> B2."ECO_ID"
and B."Kod" in ('17111', '17112', '17113', '21111', '21112', '21113')

This select DOES return six records, containing B."Kod" starting with
1711 or 2111 (one for each code in the list).

How can this happen?

Both queries have this plan:
PLAN SORT (MERGE (SORT (B2 NATURAL), SORT (B NATURAL)))

Firebird 2.1, WI-V2.1.4.18393 on Windows Server 2008 64 bit.

Kjell

--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post:kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64