vendredi 27 février 2015

best way to query for a list and then run a query for each result in that list (postgre)


I am new to databases in general and particularly new to postgresql (v 9.3). I often find myself in the situation that I first run a select statement which will return a list of users stored in an array. I then want to run a query for each user identified in the array. Right now I do this with a php for loop, but I know there must be a way to do this with prepared statements and looping within postgre. However I have not been able to find a good tutorial on how to do this, particularly how to store the results. Can anyone point me to such a resource or provide short sample code to combine a query for an array followed by a query for each item of that array and then returning the amalgamated results of these queries?


Any help would be appreciated.





Aucun commentaire:

Enregistrer un commentaire