SQL中,有效防止like的SQL注入,使用预编译SQL(?)写法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dreaming317/article/details/85060356

今天在写SQL语句的模糊查询时,遇到了防止like的SQL注入,通过查询,具体防止方法如下:

Mysql数据库

sql = " and indexNum like concat('%',?,'%') "

Oracle

sql = " like '%' || ? || '%' "

SQL Server

sql = " like '%' + ? + '%' "

猜你喜欢

转载自blog.csdn.net/dreaming317/article/details/85060356