Page 1 of 1

Query Database in situation of both [and] and [or] together

Posted: Fri Mar 06, 2015 4:52 pm
by Mark Wong

How do I query the database with something like
code{"$or": [{"and":[{"user_name": "..."},{"Receive":"..."}]},{"and":[{"user_name":"..."},{"Receive": "..."}]}]}/code
Because I need to find the target which contains for example [user_name: abc + Receive: xyz] or [username: xyz + Receive abc] at the same time
when I use the code above, it only returns
code[

]/code


Query Database in situation of both [and] and [or] together

Posted: Fri Mar 06, 2015 5:52 pm
by Alena Prykhodko

Hello,

Logical AND should be like: $and


Query Database in situation of both [and] and [or] together

Posted: Sat Mar 07, 2015 5:23 am
by Mark Wong

{"$or": [{"$and":[{"user_name": "..."},{"Receive":"..."}]},{"$and":[{"user_name":"..."},{"Receive": "..."}]}]}
its still not working....
return [ ]