Easily build a great vocabulary without studying! Now on the App Store!
Click here for more info about the app

How to cast a string of comma separated numbers into an array of integers for Postgres


If you have an string of numbers like


and you want to turn it into an array of integers you need to cast it into an integer array type.


This is commonly used together when grabbing a set using the ANY clause.

select * from users where id = any('{1,2,3}'::int[])
Tagged w/ #postgres #types #databases #sql