MySQL variable with a wildcard

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cbarnhart
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 48
Joined: Mon May 07, 2012 2:10 pm

MySQL variable with a wildcard

Post by cbarnhart » Wed Jan 29, 2014 4:49 pm

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?

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: MySQL variable with a wildcard

Post by bangkok » Wed Jan 29, 2014 4:59 pm

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

cbarnhart
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 48
Joined: Mon May 07, 2012 2:10 pm

Re: MySQL variable with a wildcard

Post by cbarnhart » Wed Jan 29, 2014 7:04 pm

Perfect - Thank you so much

Post Reply