SQLTerminal.app
now available

XPath.app
now available
Want fresh tech tips in your inbox?

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

       

If you have an string of numbers like

"1,2,3"

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

"{1,2,3}"::int[]

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

Apps I've Built

XPath Expression Editor
Practice and improve your XPath skills with XPath Editor
Click to buy on the App Store
Photo Location Changer
Easily change the location on your photos and videos
Click here for more info about the app
Photo Date Changer
Easily change the dates and times on your photos and videos
Click here for more info about the app
VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app