'Nested condition is not working in Vtiger Rest Query API

I'm trying to work with Query API to get matched results set from Vtiger.

This API works fine with normal queries (without multiple AND/ OR conditions) like: working_query = SELECT * FROM Leads WHERE id = 10x2482688 AND designation = 'SalesMan' order by createdtime LIMIT 1;

But we want to get results using nested AND/OR and those will contain parentheses. ")" and we are getting errors like 'QUERY_SYNTAX_ERROR', Syntax Error on line 1: token '(' Unexpected

Not_working_query = SELECT * FROM Leads WHERE id = 10x2482688 AND (email = '[email protected]' OR designation = 'SalesMan') order by createdtime LIMIT 1;

Any ideas on how we can resolve this?



Solution 1:[1]

Simply change your query to

SELECT * FROM Leads WHERE id = '10x2482688' AND email = '[email protected]' OR id = '10x2482688' and designation = 'SalesMan' order by createdtime LIMIT 1;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hamid