LIKE operator, %, and bind variables
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?
Subject
Views
Written By
Posted
LIKE operator, %, and bind variables
5915
August 10, 2011 10:46AM
3252
August 10, 2011 02:47PM
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.