I'm trying to do something a little different here, I'd like to use a prepared statement to implement searching for a user.
My SQL (which doesn't work) looks like:
"SELECT * from users where name like '%?%'"
(postgres 7.4 is the database)
I want to do partial matches here, but it seems to be interpreting the ? as part of the
string literal.
As expected, if I do this instead then it works but I force the user to enter % manually which I don't want to do:
"SELECT * from users where name like ?"
I know, I could just use a regular statement, but I'd rather not fumble with string concatenation if at all possible. Then I'd have to check for special charaters such as ' in the input, etc. Too much hassle!
Thoughts anyone?