Subject | RE: [firebird-support] LIKE statement and NULL field |
---|---|
Author | Alan McDonald |
Post date | 2004-02-18T07:34:12Z |
> Hi,WHERE
>
> LIKE condition returns NOT NULL fields.
>
> A Simplified Ex:
>
> SELECT COUNT(*) FROM MUHASEBE
>
> Returns 145.000
>
>
> SELECT COUNT(*) FROM MUHASEBE
> WHERE MUH_ACIKLAMA LIKE '%'
>
> Returns 138.002
>
> Because some MUH_ACIKLAMA has NULL fields.
>
> QUESTION :
>
> What can I use for this situation? I need that Null fields also.
>
> EXACT SQL:
>
> SELECT
> M.MUH_KAYITNO,
> M.MUH_TARIH,
> M.MUH_MAKBUZNO,
> M.MUH_ACIKLAMA,
> H.HAREKETKODU_TIPI
>
> FROM MUHASEBE M
> JOIN HAREKETKODLARI H
> ON M.MUH_HAREKETKODU = H.HAREKETKODU
> WHERE
> (MUH_KAYITNO LIKE :KAYITNO)
> AND
> (MUH_TARIH LIKE :TARIH)
> AND
> (MUH_MAKBUZNO LIKE :EVRAKNO)
> AND
> (MUH_ACIKLAMA LIKE :ACIKLAMA)
> ORDER BY MUH_KAYITNO
>
> All the parameters are % at the beginning and this SQL. Some of
> them are changing by user. And result must include NULLs
>
> Regards.
>
(MUH_KAYITNO LIKE :KAYITNO OR MUH_KAYITNO IS NULL)
AND
(MUH_TARIH LIKE :TARIH OR MUH_TARIH IS NULL)
AND
(MUH_MAKBUZNO LIKE :EVRAKNO OR MUH_MAKBUZNO IS NULL)
AND
(MUH_ACIKLAMA LIKE :ACIKLAMA OR MUH_ACIKLAMA IS NULL)
Is that what you need?
Alan