0

I am using Postgres for my Javascript project and I have an array of id's. Is there a way to return all the rows and their corresponding data using each id in the array.

Array of Id's

I want to return all the rows that has the id that is in the array.

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
Donobuz
  • 61
  • 10

1 Answers1

2

One of various ways: pass an array literal to the = ANY construct:

SELECT * FROM tbl WHERE id = ANY ('{46995, 54262, 73166}');

See:

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228