python mysql 查询(in 、 like)

2022年12月30日11:26:32

python进行mysql多条件查询

python 进行mysql多条件查询

基础sql

sql = "select * from table where 1 = 1 "

in 条件添加

id_list_in为字符串

sql += " and id in (%s)" % ','.join(["'%s'" % id for id in id_list_in])

like 条件添加

name_in为字符串

sql += " and name like '%s%%%%'" % (name_in)

  • 作者:little_bla
  • 原文链接:https://blog.csdn.net/qq_40330291/article/details/127113436
    更新时间:2022年12月30日11:26:32 ,共 203 字。