pymysql多条件动态查询(含模糊查询)
作者:
寒冰助手 | 来源:发表于
2021-01-14 17:24 被阅读0次sql = 'select * from order_info where (pay_time > "{0}" or "{0}"="None") and (pay_time < "{1}" or "{1}"="None") and (order_id like "%{2}%" or "{2}"="None") and (other_info like "%{3}%" or "{3}"="None") and (platform like "%{4}%" or "{4}"="None") and (tracking like "%{5}%" or "{5}"="None") and (operater = "{6}" or "{6}"="None")'.format(start_time, end_time, order_id, name, platform, tracking, operater)
mysql.execute(sql)
res = mysql.fetchall()
本文标题:pymysql多条件动态查询(含模糊查询)
本文链接:https://www.haomeiwen.com/subject/ajwvaktx.html
网友评论