如何在 Codeginter 中使用 SQL BETWEEN 运算符 Select 多个价格范围内的数据

How to Select Data Within a multiple Price Range of Values with SQL BETWEEN Operator in Codeginter

价格范围过滤器。

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)

.....等等

使用这个 where 条件。

$this->db->where('(sales  >= 0 AND <= 10) OR (sales  >= 15 AND <= 20) OR (sales  >= 60 AND <= 100)',NULL, FALSE );

我猜你问的是组函数

$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)