Search code examples
socratasoda

How to query for two where clauses


Have trouble getting multiple results. I can achieve what i want with a couple calls to the API endpoint but i wanted to make sure i wasn't missing something.

Endpoint: https://data.cms.gov/resource/vzbp-x4iv.json

I am using this for multiple codes but one state and it works fine.

https://data.cms.gov/resource/vzbp-x4iv.json?$$app_token=XXX&$where=hcpcs%20in(%27CODE1%27,%27CODE2%27)&referring_provider_state=Ohio

In SQL I would write it as ...

SELECT ...
FROM hcpcs
LEFT JOIN referral_state ...
WHERE hcpcs in ('code1', 'code2') 
AND (referral_state = 'State1'
OR referral_state = 'state2'
OR referral_state = 'state3 ... )

Solution

  • If you want to combine multiple $where clauses into a single query, you can just AND or OR them together like you'd do in SQL:

    https://dev.socrata.com/docs/queries/where.html

    Is that what you were thinking?