From: | Rodrigo E(dot) De León Plicet <rdeleonp(at)gmail(dot)com> |
---|---|
To: | Keaton Adams <kadams(at)mxlogic(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Check if column is substring of another column |
Date: | 2009-01-22 05:11:48 |
Message-ID: | a55915760901212111x6b205120g5117fbd61b187645@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Jan 21, 2009 at 5:44 PM, Keaton Adams <kadams(at)mxlogic(dot)com> wrote:
> Is there a way to do this in a single SQL statement in PostgreSQL 8.1?
SELECT
d.policyNumber
, d.CompanyName
, d.Address
, p.AllPolicyNumbersIncluded
FROM PolicyPrint p
INNER JOIN PolicyDetails d
ON (
p.cicPolicyNumber = d.policyNumber
OR
p.AllPolicyNumbersIncluded LIKE '%' || d.policyNumber || '%'
)
-- OR --
SELECT
d.policyNumber
, d.CompanyName
, d.Address
, p.AllPolicyNumbersIncluded
FROM PolicyPrint p
INNER JOIN PolicyDetails d
ON (
p.cicPolicyNumber = d.policyNumber
OR
d.policyNumber = ANY(string_to_array(p.AllPolicyNumbersIncluded, ','))
)
From | Date | Subject | |
---|---|---|---|
Next Message | Abdul Rahman | 2009-01-22 06:06:00 | Re: autovacuum daemon |
Previous Message | Hannu Krosing | 2009-01-22 01:26:17 | Re: [Plproxy-users] A complex plproxy query |