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
  • 539,169
  • 125
  • 977
  • 1,137
Donobuz
  • 51
  • 8

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
  • 539,169
  • 125
  • 977
  • 1,137