我怎样才能在mysql数据库中查询到codeigniter框架。我的查询显示不等于admin的位置。这是我的查询
$query = $this->db->query('SELECT tbl_user_type.position, tbl_users.user_id, tbl_users.user_fname, tbl_users.user_lname,
tbl_users.user_mname FROM tbl_users INNER JOIN tbl_user_type ON tbl_users.user_type = tbl_user_type.user_type
WHERE !(tbl_user_type.position = Admin) ');
return $query->result();
答案 0 :(得分:0)
尝试一下。
$query = $this->db->query('SELECT tbl_user_type.position, tbl_users.user_id, tbl_users.user_fname, tbl_users.user_lname,
tbl_users.user_mname FROM tbl_users INNER JOIN tbl_user_type ON tbl_users.user_type = tbl_user_type.user_type
WHERE tbl_user_type.position != "Admin" ');
return $query->result();
OR
$query = $this->db->query('SELECT tbl_user_type.position, tbl_users.user_id, tbl_users.user_fname, tbl_users.user_lname,
tbl_users.user_mname FROM tbl_users INNER JOIN tbl_user_type ON tbl_users.user_type = tbl_user_type.user_type
WHERE tbl_user_type.position <> "Admin" ');
return $query->result();
答案 1 :(得分:0)
试试吧......
$this->db->where('tbl_user_type.position !=','Admin');
$query = $this->db->query('SELECT tbl_user_type.position, tbl_users.user_id, tbl_users.user_fname, tbl_users.user_lname,
tbl_users.user_mname FROM tbl_users INNER JOIN tbl_user_type ON tbl_users.user_type = tbl_user_type.user_type');
return $query->result();
答案 2 :(得分:0)
请使用活动记录查询来执行此任务,使用codeigniter中的活动记录会更简单。
$this->db->select("UT.position, U.user_id, U.user_fname, U.user_lname, U.user_mname");
$this->db->from("tbl_users AS U");
$this->db->join("tbl_user_type AS UT", "U.user_type = UT.user_type");
$this->db->where("UT.position !=", "Admin");
$query = $this->db->get();
return $query->result();
用上面的代码替换您的查询。它会解决你的问题。