sqlite3.OperationalError: near "%": syntax error searching wildcard
sqlite3.OperationalError: near "%": syntax error searching wildcard
我正在尝试执行一个查询,以使用带通配符和占位符的给定字母来搜索所有名称
cursor.execute("SELECT * FROM article WHERE name LIKE %(?)%", (letter,)).fetchall()
但我一直收到此错误
sqlite3.OperationalError: near "%": syntax error
您必须将通配符连接到占位符:
cursor.execute("SELECT * FROM article WHERE name LIKE '%' || ? || '%'", (letter,)).fetchall()
我正在尝试执行一个查询,以使用带通配符和占位符的给定字母来搜索所有名称
cursor.execute("SELECT * FROM article WHERE name LIKE %(?)%", (letter,)).fetchall()
但我一直收到此错误
sqlite3.OperationalError: near "%": syntax error
您必须将通配符连接到占位符:
cursor.execute("SELECT * FROM article WHERE name LIKE '%' || ? || '%'", (letter,)).fetchall()