使用Like的MySQL参数化查询 [英] MySQL Parameterized Query using Like
本文介绍了使用Like的MySQL参数化查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在MySQL中运行这样的查询:
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%'
推荐答案
%
符号必须位于参数值内,因此更像是:
The %
symbols need to be inside the parameter value, so it's something more like:
select * from table where column1 like ?;
然后将参数设置为:
%searchText%
这篇关于使用Like的MySQL参数化查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文