Search Postgresql Archives

Re: Check if column is substring of another column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 21, 2009 at 5:44 PM, Keaton Adams <kadams@xxxxxxxxxxx> 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, ','))
    )

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux