Reputation: 91
I got two tables
patient table
+----+-------------+-----+
| id | name | age |
+----+-------------+-----+
| 1 | justin john | 49 |
| 2 | tim blake | 51 |
+----+-------------+-----+
checkup table
+-----+------------+------------+
| cid | patient_id | date |
+-----+------------+------------+
| 1 | 1 | 2016-11-02 |
| 2 | 2 | 2016-11-03 |
+-----+------------+------------+
i want to join both tables on the following condition
SELECT patient.id, patient.name, patient.age, checkup.date FROM patient LEFT JOIN checkup ON patient.id = checkup.patient_id WHERE patient.age > 50 AND checkup.date = '2016-11-03'
how can i achieve the above with OData $filter. Is $filter only applicable to top-level entity set patient ?
Upvotes: 2
Views: 8651
Reputation: 3681
You can filter on related objects using the any
and all
filters for example here is a URL for the example OData TripPin services that shows how this can be used: http://services.odata.org/V4/TripPinServiceRW/People?$filter=UserName eq 'russellwhyte' and Trips/any(x: x/Name eq 'Trip in US')
This URL filters on the UserName
property of the Person
and the Name
property of the related Trip
Upvotes: 2