php 不等于mysql查询codeigniter中的条件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32644582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:05:54  来源:igfitidea点击:

Not equal to condition in mysql query codeigniter

phpmysqlcodeigniter

提问by Hanan Ashraf

This My Model Code:

这是我的型号代码:

    public function select($id)
    {           
        $this->db->select('Something');    
        $this->db->from('tbl_somthing');
        $this->db->where('tbl_somthing.User_id',$id);
        $this->db->where('tbl_somthing.Something',0,FALSE);
        $query = $this->db->get();
        return $query->result();
    }

How could I select only non zero values from the field Something? Above query is not working.

我怎么能从字段Something中只选择非零值?上面的查询不起作用。

回答by Mohan

Try this :

尝试这个 :

public function select($id){

        return $this->db->select('Something');    
                    ->from('tbl_somthing');
                    ->where('tbl_somthing.User_id',$id);
                    ->where('tbl_somthing.Something != ',0,FALSE);
                    ->get()->result();
    }

回答by Sandeep Kumar

Try this

尝试这个

We can use simply way to find out the not equal value from the codeigniter mysqli query:

我们可以使用简单的方法从 codeigniter mysqli 查询中找出不相等的值:

$this->db->where('tbl_tabel_name != ', $id_name);  //correct way

回答by dancun chiriga

This will works sweetly too:

这也很有效:

    <?php
     $my_query = $this->db->get_where('my_table' , array(
                           'table_row!='=> NULL
    ))->result_array();
    ?>

Enjoy :)

享受 :)

回答by imtaher

also done with

也完成了

$this->db->where('columnName !=','string');