23

I want to run a query like this in MySQL:

select * from table where column1 like '%searchdata%'

But I want to use a parameter to pass in the search text. Is this possible? This doesn't seem to work:

select * from table where column1 like '%?Parameter%'

1 Answer 1

46

The % symbols need to be inside the parameter value, so it's something more like:

select * from table where column1 like ?;

And then you set the parameter to:

%searchText%
Sign up to request clarification or add additional context in comments.

1 Comment

Ahh, the sound of my hand hitting my forehead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.