Re: Check if column is substring of another column - Mailing list pgsql-general

From Rodrigo E. De León Plicet
Subject Re: Check if column is substring of another column
Date
Msg-id a55915760901212111x6b205120g5117fbd61b187645@mail.gmail.com
Whole thread Raw
In response to Check if column is substring of another column  (Keaton Adams <kadams@mxlogic.com>)
List pgsql-general
On Wed, Jan 21, 2009 at 5:44 PM, Keaton Adams <kadams@mxlogic.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, ','))
    )

pgsql-general by date:

Previous
From: Keaton Adams
Date:
Subject: Check if column is substring of another column
Next
From: Abdul Rahman
Date:
Subject: Re: autovacuum daemon