ands and ors execution order
Closed this issue · 4 comments
Hi guys,
I've come across to an other issue due to my complex query which can have a lot of ands and ors.
What I have seen so far is that the result is totally wrong compared to a real MySQL query result executing the same query.
I read there is a limitation saying the ands are executed before the ors, which could explain why my results are wrong.
I have tried to decompose the query by running the ors first then the ands, but even this does not satisfy me...
I have re-uploaded the json file and the php code containing the query.
Would there be a better way to do so ?
Regards,
DuncanV
This is how the query is being interpreted:
(@.organisation.id >= 3 and @.organisation.id <= 5 and @.tier >= 1 and @.tier <= 3 and @.attributes[8].value.value == 34) or
(@.attributes[8].value.value == 68 and @.tier == 2 and @.attributes[43].value.value == 1) or
(@.attributes[27].value.value == 1) or
(@.attributes[43].value.value == 2) or
(@.attributes[27].value.value == 2) or
(@.attributes[43].value.value == 3) or
(@.attributes[27].value.value == 3) or
(@.attributes[43].value.value == 4) or
(@.attributes[27].value.value == 4) or
(@.attributes[43].value.value == 5) or
(@.attributes[27].value.value == 5) or
(@.attributes[43].value.value == 6) or
(@.attributes[27].value.value == 6)
Can you confirm if that is what you meant to query?
Hi @Galbar ,
The query would look like :
@.organisation.id >= 3
and @.organisation.id <= 5
and @.tier >= 1
and @.tier <= 3
and ( @.attributes[8].value.value == 34 or @.attributes[8].value.value == 68 )
and @.tier == 2
and (
@.attributes[43].value.value == 1 or @.attributes[27].value.value == 1
or @.attributes[43].value.value == 2 or @.attributes[27].value.value == 2
or @.attributes[43].value.value == 3 or @.attributes[27].value.value == 3
or @.attributes[43].value.value == 4 or @.attributes[27].value.value == 4
or @.attributes[43].value.value == 5 or @.attributes[27].value.value == 5
or @.attributes[43].value.value == 6 or @.attributes[27].value.value == 6
)
It would expand to something like this:
$.data[?(
@.organisation.id >= 3
and @.organisation.id <= 5
and @.tier >= 1
and @.tier <= 3
and @.attributes[8].value.value == 34
and @.tier == 2
and @.attributes[27].value.value >= 1
and @.attributes[27].value.value <= 6
or
@.organisation.id >= 3
and @.organisation.id <= 5
and @.tier >= 1
and @.tier <= 3
and @.attributes[8].value.value == 68
and @.tier == 2
and @.attributes[27].value.value >= 1
and @.attributes[27].value.value <= 6
or
@.organisation.id >= 3
and @.organisation.id <= 5
and @.tier >= 1
and @.tier <= 3
and @.attributes[8].value.value == 34
and @.tier == 2
and @.attributes[43].value.value >= 1
and @.attributes[43].value.value <= 6
or
@.organisation.id >= 3
and @.organisation.id <= 5
and @.tier >= 1
and @.tier <= 3
and @.attributes[8].value.value == 68
and @.tier == 2
and @.attributes[43].value.value >= 1
and @.attributes[43].value.value <= 6
)]
Oh Okay.
Will try this out and let you know :-)
Many thanks.