Received: from smtp.stellison.co.uk ([212.56.66.225]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id eB7LRvP00267 for ; Thu, 7 Dec 2000 16:27:57 -0500 (EST) (envelope-from francis@stellison.co.uk) Received: (qmail 21300 invoked from network); 7 Dec 2000 21:28:16 -0000 Received: from unknown (HELO neo) (unknown) by unknown with SMTP; 7 Dec 2000 21:28:16 -0000 From: "Francis Solomon" To: "Beth Gatewood" , Subject: RE: trying to pattern match to a value contained in a column Date: Thu, 7 Dec 2000 21:28:55 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 In-Reply-To: <3A2FFBB4.7B5156DA@mbt.washington.edu> Importance: Normal X-Archive-Number: 200012/47 X-Sequence-Number: 378 Hi Beth, Try something like this ... Here's a simple table schema: CREATE TABLE abbrev ( abbr varchar(10), long_name varchar(50), primary key(abbr) ); Throw in some random data: INSERT INTO abbrev VALUES ('fs', 'fsolomon'); INSERT INTO abbrev VALUES ('bg', 'bgatewood'); INSERT INTO abbrev VALUES ('junk', 'nomatch'); Query the table: SELECT * FROM abbrev WHERE long_name~abbr; ... which yields these results: abbr | long_name ------+----------- fs | fsolomon bg | bgatewood Note that ~ does a case-sensitive regex match. If you really want a 'like' match, you could do this instead: SELECT * FROM abbrev where long_name~~('%' || abbr || '%'); ... where '||' is the string-concatenation operator. Hope this helps Francis Solomon > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Beth Gatewood > Sent: 07 December 2000 21:06 > To: pgsql-sql@postgresql.org > Subject: [SQL] trying to pattern match to a value contained > in a column > > > Hi- > > I can't figure out how to do this.... > > I examine a table where I think that one attribute is an > abbreviation of > another attribute. > > So-If I had a table where I had LONG_NAME and ABBR as attributes. > > I want something like > > SELECT whatever FROM my_table WHERE long_name LIKE '%[the > value of ABBR > in that row]%'; > > > Of course this doesn't work... > > Any thoughts? > > Thanks- > Beth > > >