How can I query a list of object by list Id in Vercel/Postgres?
I tried:
const dataOTP = await sql<OTP>`
SELECT *
FROM otps
WHERE id IN (${listOTPId.join(", ")})
`;
But it got 22P02 ERROR.
When I try another way like this, it worked correctly:
const dataOTP = await sql<OTP>`
SELECT *
FROM otps
WHERE id IN (${listOTPId[0]}, ${listOTPId[1]})
`;
Someone can tell me why?
New contributor
DragonPi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.