Page 1 of 1

Concatenate variable with LIKE clause

Posted: Tue Sep 19, 2017 7:29 pm
by gabrielw3n
Hello.

Please, I would like to concatenate an "AND" clause based on a variable value but I'm getting errors because of the 'LIKE' and '%%'.

This is what I'm doing:

Code: Select all

{occurrenceType == "M" ? " AND occurrence.fk_doc = " + doctor + "" : " AND patient.nameLIKE '%'" + {patient_name} + "%'"}
Please, I'm geting SQL errors.

What is the correct way to escape a single quotation mark or use a clause WHERE using a variable?

Re: Concatenate variable with LIKE clause

Posted: Wed Sep 20, 2017 5:22 am
by Edward
Hi Gabriel,

I have noticed that you have got nested curly brackets in that expression, that is not supported, please try to modify your expression like follows:

Code: Select all

{ occurrenceType == "M" ? " AND occurrence.fk_doc = " + doctor + "" : " AND patient.name LIKE '%'" + patient_name + "%'"}
Thank you,
Edward