Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread How to use IN in a query with params
Tue, Oct 17 2017 11:44 PMPermanent Link

Paul Coshott

Avatar

Hi All,

I want to implement a compare feature for items in a table. Each item has an ItemId (integer).

I created the following query:

Select * From Items
 where ItemId IN ({ItemId=1,2})

I have tried a few slightly different formats, but can't figure out how to create a query that allows params for use with IN, so I can add a few items.

Any idea how to do this, or is there a better way to do what I want to accomplish?

Cheers,
Paul
Wed, Oct 18 2017 1:59 AMPermanent Link

Jiri Dvorsky

Avatar

See
https://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_server&page=1&msg=81#81
------------------------------------------------------------------------------------------------------------------------------------------------

Paul Coshott wrote:

Hi All,

I want to implement a compare feature for items in a table. Each item has an ItemId (integer).

I created the following query:

Select * From Items
 where ItemId IN ({ItemId=1,2})

I have tried a few slightly different formats, but can't figure out how to create a query that allows params for use with IN, so I can add a few items.

Any idea how to do this, or is there a better way to do what I want to accomplish?

Cheers,
Paul
Wed, Oct 18 2017 3:11 AMPermanent Link

Uli Becker

Paul,

> Any idea how to do this, or is there a better way to do what I want to accomplish?

As Jiri indicated, it's not possible this way.

As a workaround you could write the ID's you want to compare in a
separate table (TempTable) and use a query like this:

SELECT * FROM Items WHERE ItemId IN (SELECT ItemID FROM TempTable);

Another (clean) way to get what you want is to use a module and pass the
ID's either as separate params or as a list.

Cheers Uli
Wed, Oct 18 2017 8:19 AMPermanent Link

Paul Coshott

Avatar

Hi Guys,

Thanks for the help. I think a module would be best, as ultimately I want to return a pdf report anyway.

Thanks,
Paul


>>Another (clean) way to get what you want is to use a module and pass the
>>ID's either as separate params or as a list.
Image