LIKE operator, %, and bind variables
Posted by: Douglas Duvall
Date: August 10, 2011 10:46AM

I am using the C API, MYSQL version 5.1.51

Here is my prepared select statement.
NOTE: I am searching for PATTERSON%, i.e anything starting with PATTERSON
select pifile from pifile where nameSort like ?
Now when I set the data for the question mark, I use PATTERSON%. After I execute,
I get no data. However, if I run the statement in Workbench,
i.e. select pifile from pifile where nameSort like "PATTERSON%", I get everything starting with PATTERSON. What's the problem with using the prepared statement. It must think the % is a literal character to look for instead of thinking it's a wild card character. How do you use wild card characters in prepared statements?

Options: ReplyQuote


Subject
Views
Written By
Posted
LIKE operator, %, and bind variables
5915
August 10, 2011 10:46AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.