I am trying to do a query to search all name with giving letter with wild card and placeholder
cursor.execute("SELECT * FROM article WHERE name LIKE %(?)%", (letter,)).fetchall()
but I am keep getting this error
sqlite3.OperationalError: near "%": syntax error
CodePudding user response:
You must concatenate the wildcards to the placeholder:
cursor.execute("SELECT * FROM article WHERE name LIKE '%' || ? || '%'", (letter,)).fetchall()