Search Postgresql Archives

Check if column is substring of another column

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

 



Title: Check if column is substring of another column
PostgreSQL 8.1 question:

I have two columns.
policyNumber contains a 12-13 varchar string
AllPolicyNumbersIncluded contains one or more 12-13 varchar strings (policy nums) separated by commas

I want to check if policyNumber is contained in AllPolicyNumbersIncluded.

In SQL Server the PATINDEX function returns the starting position of the first occurrence of a pattern in a specified _expression_, or zeros if the pattern is not found, on all valid text and character data types, so something like this works:

SELECT me.policyNumber, me.CompanyName, me.Address, PolicyPrint.AllPolicyNumbersIncluded
FROM PolicyPrint INNER JOIN PolicyDetails me
ON (PolicyPrint.cicPolicyNumber = PolicyDetails.policyNumber
OR PATINDEX('%' + me.policyNumber + '%',cicPrint.AllPolicyNumbersIncluded)> 0 )

Is there a way to do this in a single SQL statement in PostgreSQL 8.1?

Thanks,

Keaton


[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