X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2F70BD1B53A for ; Wed, 12 Nov 2003 14:39:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 91126-10 for ; Wed, 12 Nov 2003 10:39:04 -0400 (AST) Received: from lucifer.oficina (unknown [200.69.203.237]) by svr1.postgresql.org (Postfix) with ESMTP id 841ECD1B51C for ; Wed, 12 Nov 2003 10:38:59 -0400 (AST) Received: from [192.168.1.190] (taz.oficina [192.168.1.190]) (authenticated bits=0) by lucifer.oficina (8.12.9/8.12.9) with ESMTP id hACEcWmh013907; Wed, 12 Nov 2003 11:38:32 -0300 (ART) (envelope-from franco@akyasociados.com.ar) Subject: Re: SQL substring From: Franco Bruno Borghesi To: Guy Korland Cc: pgsql-sql@postgresql.org In-Reply-To: <00ea01c3a926$4049b6d0$4a264484@cs.technion.ac.il> References: <00ea01c3a926$4049b6d0$4a264484@cs.technion.ac.il> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-rftWn9rMBAnYNp59QsNB" Organization: AK y Asociados S.R.L. Message-Id: <1068647911.4251.3.camel@taz> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Wed, 12 Nov 2003 11:38:31 -0300 X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/138 X-Sequence-Number: 15953 --=-rftWn9rMBAnYNp59QsNB Content-Type: multipart/alternative; boundary="=-AhseSbKVJhekBlV4TW5A" --=-AhseSbKVJhekBlV4TW5A Content-Type: text/plain Content-Transfer-Encoding: quoted-printable ... WHERE field1 LIKE '%' || field2 || '%' or ... WHERE position(field2 in field1)>0 On Wed, 2003-11-12 at 11:07, Guy Korland wrote: > Hi, > How can I compare two fields if one is a substring of the other? > Something like:=20 > ... WHERE StringA like '%' + StringB + '%'; >=20 > Thanks, > Guy Korland >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend >=20 --=-AhseSbKVJhekBlV4TW5A Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable ... WHERE field1 LIKE '%' || field2 || '%'
or
... WHERE position(field2 in field1)>0

On Wed, 2003-11-12 at 11:07, Guy Korland wrote:
Hi,
How can I compare two fields if one is a substring of the other?
Something like:=20
	... WHERE StringA like '%' + StringB + '%';

Thanks,
Guy Korland


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
--=-AhseSbKVJhekBlV4TW5A-- --=-rftWn9rMBAnYNp59QsNB Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQA/skXm21dVnhLsBV0RAqTZAJ906fz+5TV0FA75XGw5Epcf49LiRgCdEEru send2mKgeFK6fEU+wHr9gNs= =WF9B -----END PGP SIGNATURE----- --=-rftWn9rMBAnYNp59QsNB--