0

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 = 'test@yahoo.com' OR designation = 'SalesMan') order by createdtime LIMIT 1;

Any ideas on how we can resolve this?

Paresh
  • 3
  • 2

1 Answers1

0

Simply change your query to

SELECT * FROM Leads WHERE id = '10x2482688' AND email = 'test@yahoo.com' OR id = '10x2482688' and designation = 'SalesMan' order by createdtime LIMIT 1;
Hamid
  • 378
  • 3
  • 8
  • Thanks for the answer. It's useful but in the case of multi-level nesting, this solution will create more complexity, and also I can see performance for such operations is not quite good. API will take a much longer time to get executed. – Paresh May 03 '22 at 05:47