Select multiple rows with a string of id seperated by commas

Hey there!

I have been looking around for an answer for a while but i'm out of luck. Basically what I'm trying to do is to select all items in TABLE1 with ID IN = LINKID, LINKID is a dynamic string of arrays in TABLE2 and looks like this: 1,2,3,..

So this is the code i want to work:

SELECT * FROM itemorders WHERE ID IN ({{listCollection4.selectedItem.linkid}});

Error code: invalid input syntax for type integer: "22,23,24"

This is the workaround code that is "working":

SELECT * FROM itemorders WHERE ID IN (22,23,24);

I have added some pictures for clarification, thanks for the help! :smile:




Skärmbild 2024-03-15 150854

Hi Isack

Instead of:
SELECT * FROM itemorders WHERE ID IN ( {{listCollection4.selectedItem.linkid}} );

Try:
SELECT * FROM itemorders WHERE ID = ANY( {{listCollection4.selectedItem.linkid}} );

Hi @Isack98, welcome to the forum! :wave:

I recommend going through this SQL Cheatsheet. :slightly_smiling_face:

1 Like