I'm currently trying to pull in some rows, based on the contents of an array found in a column from another table. So far I have:
SELECT * FROM coaches WHERE id = ANY(SELECT unnest({23,23,13}) FROM stations WHERE id = 1
All is fine, but I only get back one entry for number 23. I'm assuming this is to cut down on duplicates, but I actually want the duplicates. I want all the data for number 23 twice, and then number 13 once, to match up with the array of {23,23,13}
. I also want it to arrive in the same order.
Hopefully this makes sense... any help would be great. I'm new to this, so sorry if its obvious.