Django框架 之 查询 Extra的where里如何写lik
查询Extra的where里写like后置匹配关键词逻辑,代码示例:
sqlWhere = ['name like %s']
sqlParam = ['%' +keyword]
markets = WFmarket.objects.extra(where=sqlWhere, params=sqlParam)
查询Extra的where里写like前置匹配关键词逻辑,代码示例:
sqlWhere = ['name like %s']
sqlParam = [keyword + '%' ]
markets = WFmarket.objects.extra(where=sqlWhere, params=sqlParam)
查询Filter的字段包含关键词匹配逻辑(不匹配大小写字母敏感),代码示例:
markets = WFmarket.objects.filter(cn_name__icontains=keyword)
查询Filter的字段包含关键词匹配逻辑(匹配大小写字母敏感),代码示例:
markets = WFmarket.objects.filter(cn_name__contains=keyword)
本文标题:Django框架 之 查询 Extra的where里如何写lik
本文链接:https://www.haomeiwen.com/subject/rncdpftx.html
网友评论