Why can this return items not containing "50%"?
# input = '50%' (parameterized)
cur.execute(
"SELECT * FROM items WHERE name LIKE ?",
('%' + input + '%',))
- The driver strips the
%signs - Parameters disable the
LIKEmatch - The
%in input acts as a wildcard LIKEhere compares numbers only
Binding stops injection but not pattern meaning: escape
Play SQL & Databases ▸
% and _ and add an ESCAPE clause.