From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Alexander Blüm <mailinglists1(at)gmx(dot)de> |
Cc: | Postgresql General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: query-question |
Date: | 2003-09-11 15:04:09 |
Message-ID: | 20030911080207.B29873-100000@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 11 Sep 2003, [ISO-8859-1] Alexander Blm wrote:
> hello,
>
> I'm facing an odd problem.
> I have a query:
>
> SELECT "Krzel", "Autor(en)", "Titel"
> FROM "tblTitelangaben"
> WHERE "Titel"||"Krzel"||"Monographie-Krzel"||"Autor(en)" ILIKE '%er%';
>
> this works like a charm.
>
> but if I add another ||"something" - which might be emtpy, I get no
> results.. why?
>
> WHERE
> "Titel"||"Krzel"||"Monographie-Krzel"||"Autor(en)"||"Herausgeber"
> ILIKE '%er%';
>
> || is the same as "OR", is it not?
No, it's string concatenation. Also, remember that NULLs are special
a || NULL is NULL. You can use coalesce(field,"") to get an empty string
if field is NULL.
> 1 OR 0 = 1
> 1 OR 1 = 1
> 0 OR 0 = 0
> right?
And even for OR, the above isn't true in SQL because of NULLs.
1 | 0 | N
1 1 | 1 | N
0 1 | 0 | N
N N | N | N
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Blüm | 2003-09-11 15:17:40 | Re: query-question |
Previous Message | Vivek Khera | 2003-09-11 14:55:05 | Re: A Question About Insertions -- Performance |