php - 如何在 Codeginter 中使用 SQL BETWEEN 运算符在多个价格范围内选择数据

标签 php mysql codeigniter between

价格范围过滤器。

EX:>(0 到 10 和 15 到 20 以及 60 到 100)

$this->db->where('sales'  >= 0)

$this->db->where('sales'  <= 10)

$this->db->where('sales'  >= 15)

$this->db->where('sales'  <= 20)

.....等等

最佳答案

我猜你问的是组函数

$this->db->group_start();
  $this->db->where('sales >= ',  0);
  $this->db->where('sales <=',  10);
$this->db->group_end();
$this->db->or_group_start();
  $this->db->where('sales >=',  15);
  $this->db->where('sales <=',  20);
$this->db->group_end();

会产生

(`sales` >= 0 and `sales` <= 10) or (`sales` >= 15 and `sales` <= 20)

关于php - 如何在 Codeginter 中使用 SQL BETWEEN 运算符在多个价格范围内选择数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54145164/

相关文章:

php - 动态执行多个 $_FILES 时更改第一个输入字段名称

php - 在 Codeigniter 中放在哪里以及如何加载结果对象类?

php - 只选择一个单选按钮,但由于 PHP 的原因,它们不能具有相同的名称

PHP 扩展 imagick 3.5.0 for PHP 8 : installation on macos fails

php - Android 服务连接到服务器

mysql - SQL:通过将两列相互映射来更新表

php - 如何使用 Bootstrap 和 SQL 查询在循环中连续显示 4 列

php - 在 Hero Framework 主题中的 .thtml 文件中执行 php

java - Hibernate 在选择查询中生成过多的连接

php - 图像版本控制 - 最佳方法