[英]SQL Server - Python - How to use the wildcard % in tuple for where statement?
[英]How to use %x% wildcard in python using SQL
input_uni = request.form.get("search")
uni = db.execute("SELECT * FROM unis WHERE name LIKE :name OR country LIKE :country", name=input_uni, country=input_uni)
您可以在参数名称周围使用 concat 来构建正确的类似模式,而不会出现 % 问题
SELECT * FROM unis WHERE name LIKE concat('%', :name, '%')
OR country LIKE concat('%', :country, '%');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.