在WHERE条件下使用BETWEEN [英] using BETWEEN in WHERE condition

查看:432
本文介绍了在WHERE条件下使用BETWEEN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此函数中如何选择minvalue& maxvalue之间住宿的酒店

Here in this function How to select hotels where accommodation between minvalue&maxvalue

function gethotels($state_id,$city,$accommodation,$minvalue,$maxvalue,$limit,$pgoffset)
    {
        $this->db->limit($limit, $pgoffset);
        $this->db->order_by("id", "desc");
        $this->db->where('state_id',$state_id);
        $this->db->where('city',$city);
        $this->db->where($accommodation,$minvalue);
        $result_hotels = $this->db->get('hotels');
        return $result_hotels->result();

   }


推荐答案

使用

$this->db->where('$accommodation >=', minvalue);
$this->db->where('$accommodation <=', maxvalue);

我不确定语法,所以我请求你原谅,如果不正确。
无论如何 BETWEEN 是使用> = min&& < = max。

这是我的例子的意思。

I'm not sure of syntax, so I beg your pardon if it's not correct.
Anyway BETWEEN is implemented using >=min && <=max.
This is the meaning of my example.

EDITED:

查看此链接我认为您可以写: / p>

EDITED:
Looking at this link I think you could write:

$this->db->where("$accommodation BETWEEN $minvalue AND $maxvalue");

这篇关于在WHERE条件下使用BETWEEN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆