We help IT Professionals succeed at work.

Using the equivalent of in operator in a query for REST API

Gerhardpet
Gerhardpet asked
on
What is the equivalent of an in operator in a query for REST API using a filter

Here is a sample URL where I filter for the customer number and I want to filter for multiple values

{{url}}/{{company}}/sales/invoices/?filter={"customer.customerNo": "CASH"}

To query this same data in the database I have

select * from customers where cust_no in ('CASH','ABC','123')
Comment
Watch Question

Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016

Commented:
If you dont want to use IN then you can use OR. This should work in any DB.

select * from customers where
cust_no = 'CASH'   OR  cust_no =  'ABC'  OR cust_no =  '123'

Author

Commented:
Please read my question again. You missed my point.
Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016

Commented:
Please try like this -

{{url}}/{{company}}/sales/invoices/?filter=("customer.customerNo": "CASH") OR ("customer.customerNo": "ABC")  OR ("customer.customerNo": "123")

You can read more from - https://sharepoint.stackexchange.com/questions/163307/rest-api-filter-multiple-values

Author

Commented:
That does not work for REST API. Do you have experience using the REST API?
I found the answer elsewhere

This is the correct parameter

{"customer.customerNo": { "$in": ["ER118","AAA222"]}}

Open in new window

Author

Commented:
I found the answer elsewhere