Search Postgresql Archives

Re: Converting string to IN query

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

 



Andrus wrote:
> String contains list of document numbers (integers) like:
> 
> '1,3,4'
> 
> How to SELECT documents whose numbers are contained in this string.

> Numbers should be passed as single string literal since FYIReporting
> RDLEngine does not allow multivalue parameters.

Hmm - might be worth bringing that to their attention.

Try string_to_array(). Example:

SELECT * FROM generate_series(1,10) s
WHERE s = ANY (string_to_array('1,3,5,7', ',')::int[]);

Note that I'm casting it to an array of integers so the "= ANY" knows
what types it will need to match.

-- 
  Richard Huxton
  Archonet Ltd


[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