Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

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

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

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

Hello,

Logical AND should be like: $and

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

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

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

Return to “Issues”