From: Holm Tiffe <holm@freibergnet.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: holm@freibergnet.de
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] problem with select
Date: Tue, 31 Aug 1999 08:29:20 +0200
Message-ID: <19990831082920.A23046@pegasus.freibergnet.de> (raw)
In-Reply-To: <5585.936024234@sss.pgh.pa.us>
References: <19990830140452.B21897@pegasus.freibergnet.de>
<5585.936024234@sss.pgh.pa.us>
Tom Lane wrote:
> Holm Tiffe <holm@freibergnet.de> writes:
> > What I try to find is a solution for a search in this table like this:
>
> > select distinct code,category from products where code ~* 'abc' or
> > category ~* 'abc' or manufacturer ~* 'abc' or description ~* 'abc'
> > or comment ~* 'abc' order by code;
>
> > So far so good, but I have the problem that I have the value 'abc'
> > only one times !
>
> How about
>
> select distinct code,category from products where
> (code || category || manufacturer || ...) ~* 'abc';
>
> Actually you'd probably want to also concatenate some separator markers,
> maybe (code || '|' || category || ...), so that you didn't get bogus
> matches across fields, like where code ends in 'a' and category starts
> with 'bc'.
>
> Note that this select will be a bit of a memory hog because
> text-slinging is very wasteful of space in 6.5 (the intermediate results
> from the concatenate operators don't get freed till end of transaction).
> So it might not be workable if you have a large database. I hope to see
> that fixed for 6.6 or 6.7.
>
> regards, tom lane
Hm, clever.
It is almost working, my database isn't that big that memory becomes a
problem; the machine has 512MB.
But why is nothing found if one value of a column contains NULL ?
select distinct code,category from products where (code || '|' || category
|| '|' || comment || '|' || description || '|' || desc_de) ~* 'kde';
code|category
------+--------
06-001|KDE
(1 row)
shop=> update products set comment = Null where code ='06-001';
UPDATE 1
shop=> select (comment || '|' || code) from products where code ~* '06-001';
?column?
--------
(1 row)
Holm
--
FreibergNet Systemhaus GbR Holm Tiffe * Administration, Development
Systemhaus für Daten- und Netzwerktechnik phone +49 3731 781279
Unternehmensgruppe Liebscher & Partner fax +49 3731 781377
D-09599 Freiberg * Am St. Niclas Schacht 13 http://www.freibergnet.de/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: holm@freibergnet.de, tgl@sss.pgh.pa.us
Subject: Re: [SQL] problem with select
In-Reply-To: <19990831082920.A23046@pegasus.freibergnet.de>
References: <19990830140452.B21897@pegasus.freibergnet.de> <5585.936024234@sss.pgh.pa.us> <19990831082920.A23046@pegasus.freibergnet.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox