Skip site navigation (1) Skip section navigation (2)

Question on joining tables

From: "Chris Pizzo" <chris(at)artinside(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Question on joining tables
Date: 2002-06-03 17:06:37
Message-ID: 00b601c20b21$05c75110$832aa8c0@itchrisp (view raw or flat)
Thread:
Lists: pgsql-novice
Hi,
I have an interesting issue where i need to join two tables where the field that jions them is similar but not identical.  Table A field data is char(12) and contains data that looks like:

BBB12345
BBB345
BBB4980
BBB3455

Table B field data is char(32) and contains data that looks like:

MMM12345
BBB345
BBB4980
MMM3455

I need a way to equate  MMM12345 to BBB12345 in the join.  I tried using substrings but this fails ie.

select some_data from A,B where (substr(A.field,4,12) = substr(B.field,4,12));

anyone point me in the right direction?

Thanks,
Chris Pizzo

Responses

pgsql-novice by date

Next:From: Tom AnsleyDate: 2002-06-03 18:48:24
Subject: JDBC issue
Previous:From: Chris PizzoDate: 2002-06-03 16:50:53
Subject: Question on joining tables

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group