在sql查询中使用like时出现语法错误

xu3bshqb  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(329)

当我像这样创建sql查询时:

param = (date, )
query = SELECT date_added from deploy_requests WHERE date_added LIKE '%s %'
query.execute(query, param)

我得到语法错误
但如果我用不推荐的方法

query = SELECT date_added from deploy_requests WHERE date_added LIKE '{} %'.format(date)
qq24tv8q

qq24tv8q1#

我想,我就是这样做的。

def get_deployment_times(date):
    date = "{}%".format(date)
    param = (date, )
    query = "SELECT date_added from deploy_requests WHERE date_added LIKE %s"

相关问题