Обсуждение: Subject: String Concatenation does not work.

Поиск
Список
Период
Сортировка

Subject: String Concatenation does not work.

От
leshan@ugsolutions.com
Дата:
>I tried to place a query like "SELECT * FROM x WHERE a = b || c" where
> a, b and c are text columns in table x.
> Unfortunately all I get are Syntax Errors pointing to the
concatenation
> operator. This happens under 6.3.<latest> with psql and jdbc.
> Am I just tripping over a bug or do have to use some kind of escaping?

> Regargs,
>        Holger Klawitter

Well in version 6.4 this works:
  SELECT * FROM x WHERE a = b or a=c;

Hope that helps.
J.L.


[GENERAL] Subject: String Concatenation DOES work.

От
Holger Klawitter
Дата:
> >I tried to place a query like "SELECT * FROM x WHERE a = b || c" where
>
> Well in version 6.4 this works:
>   SELECT * FROM x WHERE a = b or a=c;

Ahem, in PostQuel the || Operator stands for string concatenation not
for the logical or. Anyhow, I found out that under 6.4.2 the following
construct seems to work, however, all brackets are neccessary:
    SELECT * from x WHERE a ~~ (( '%' || b ) || '%' );

Thanks anyhow
    Holger Klawitter
--
Holger Klawitter
holger.klawitter@gmx.de           http://wwwmath.uni-muenster.de/~holger

Re: [GENERAL] Subject: String Concatenation DOES work.

От
Bruce Momjian
Дата:
> > >I tried to place a query like "SELECT * FROM x WHERE a = b || c" where
> >
> > Well in version 6.4 this works:
> >   SELECT * FROM x WHERE a = b or a=c;
>
> Ahem, in PostQuel the || Operator stands for string concatenation not
> for the logical or. Anyhow, I found out that under 6.4.2 the following
> construct seems to work, however, all brackets are neccessary:
>     SELECT * from x WHERE a ~~ (( '%' || b ) || '%' );

|| is the SQL standard way to do it.  I realize it seems confusing.

--
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026