将mysql查询转换为codeigniter

时间:2015-03-03 08:55:10

标签: mysql codeigniter

如何将此查询转换为codeigniter框架:

SELECT sname FROM alumni WHERE email IN (SELECT * FROM alumni_user WHERE uname = '')

2 个答案:

答案 0 :(得分:1)

试试这个..

$this->db->select('*');

$this->db->from('alumni_user');

$this->db->where('uname','');

$result = $this->db->get();

答案 1 :(得分:0)

试试这个:

$q = $this->db->query("SELECT sname FROM alumni WHERE email IN (SELECT * FROM alumni_user WHERE uname = '')");

if($q->num_rows() > 0)
{
    $data = $q->result_array();
    print_r($data);
}
else
{
    echo '';
}