Received: from chi-mx.truenorth.com (interlock.truenorth.com [199.221.98.2]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA93012 for ; Tue, 31 Aug 1999 12:25:16 -0400 (EDT) (envelope-from djackson@cpsgroup.com) Received: from cpsmail.cpsgroup.com (cpsmail.cpsgroup.com [144.210.12.10]) by chi-mx.truenorth.com (8.9.3/8.9.3) with ESMTP id LAA65335; Tue, 31 Aug 1999 11:25:05 -0500 (CDT) Received: by cpsmail with Internet Mail Service (5.5.2448.0) id ; Tue, 31 Aug 1999 11:23:41 -0500 Message-ID: From: "Jackson, DeJuan" To: holm@freibergnet.de, Tom Lane Cc: pgsql-sql@postgreSQL.org Subject: RE: [SQL] problem with select Date: Tue, 31 Aug 1999 11:23:41 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.org id MAA93073 Why? Because: NULL = NULL Therefore: (comment || code) = NULL, because comment is NULL You must remember that NULL is not the same as an empty string; NULL = undefined. Hope this helps, DEJ > -----Original Message----- > From: Holm Tiffe [SMTP:holm@freibergnet.de] > Sent: Tuesday, August 31, 1999 1:29 AM > To: Tom Lane > Cc: holm@freibergnet.de; pgsql-sql@postgreSQL.org > Subject: Re: [SQL] problem with select > > Tom Lane wrote: > > > Holm Tiffe 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/ > > > ************