Page 1 of 1

MySQL variable with a wildcard

Posted: Wed Jan 29, 2014 4:49 pm
by cbarnhart
I am trying to use a wildcard with a variable in a mySQL LIKE command for my Livecode database routine. I am a novice so I know I must be just putting the % in the wrong spot. This is what I have -

put revQueryDatabase( theConnectionID, "select * from hospaccess.v_LogFile_Viewed where UserID = '"&gpUID&"' and Organization like '"&gOrganization&"'") into theCursor

gOrganization can be in a sting of characters so I would like it to be %gOrganization% but I can not figure out where to place the "%" to be accepted in my livecode line of code

Any suggestions?

Re: MySQL variable with a wildcard

Posted: Wed Jan 29, 2014 4:59 pm
by bangkok

Code: Select all

put revQueryDatabase( theConnectionID, "select * from hospaccess.v_LogFile_Viewed where UserID = '"&gpUID&"' and Organization like '%"&gOrganization&"%'") into theCursor
% must be after first single quote
and before second single quote

Re: MySQL variable with a wildcard

Posted: Wed Jan 29, 2014 7:04 pm
by cbarnhart
Perfect - Thank you so much