SQL using Like operator for prepared statement
-
Hi all~ E.g "Select * from table_A where firstName Like '%" + string + "%'"; How to change the ad-hoc sql to prepared statement using operator 'like' and '%'? Thanks
-
Hi all~ E.g "Select * from table_A where firstName Like '%" + string + "%'"; How to change the ad-hoc sql to prepared statement using operator 'like' and '%'? Thanks
If using prepared statement, The sql will like this: cmd.CommandText = "Select * from table_A where firstName Like ?" cmd.Parameter.Add("FirstName", "John"); cmd.Prepared(); cmd.ExecuteNonQuery(); Then if I would like to get the records which the firstName contains string "John". Using ad-hoc statement, "%" operator can be used. If using prepared statement, but to put "%" operator or using other way to achieve the result.