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, ','))
)