MySQL Parameterized Query using Like

后端 未结 1 1913
悲哀的现实
悲哀的现实 2021-02-18 15:33

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

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-18 16:33

    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%
    

    0 讨论(0)
提交回复
热议问题