
如何在 python 的 orator 中构建多个 like 查询?
原生 sql 语句支持使用 or 运算符将多个 like 查询条件组合在一起,例如:
select * from `think_user` where (`name` like '%think%' or `name` like '%php%')
要将此查询转换为 orator,可以使用多次赋值方法:
and 逻辑:
新快购物系统是集合目前网络所有购物系统为参考而开发,不管从速度还是安全我们都努力做到最好,此版虽为免费版但是功能齐全,无任何错误,特点有:专业的、全面的电子商务解决方案,使您可以轻松实现网上销售;自助式开放性的数据平台,为您提供充满个性化的设计空间;功能全面、操作简单的远程管理系统,让您在家中也可实现正常销售管理;严谨实用的全新商品数据库,便于查询搜索您的商品。
0
# 实现 and 逻辑
search = ['%word1%', '%word2%', '%word3%', ...]
info = db.table('full_text')
for s in search:
info = info.where('title', 'like', s)
result = info.get()or 逻辑:
# 实现 OR 逻辑
search = ['%word1%', '%word2%', '%word3%', ...]
info = DB.table('full_text')
for s in search:
if search.index(s) == 0:
info = info.where('title', 'like', s)
else:
info = info.or_where('title', 'like', s)
result = info.get()需要特别注意的是,与原生 sql 语句不同,orator 的 like 查询使用通配符 % 包裹搜索词,而不是使用百分号占位符。
以上就是如何在 Orator 中使用多个 LIKE 查询?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号