您好我想加入三个表,但它从用户表中获取所有数据,我只想要firstname和lastname参数
这是我的连接查询 . 我想要一些像join(user.firstname)的东西 .
$this->db->select('*');
$this->db->from('post');
$this->db->join('user', 'user.id = post.cop_id');
$this->db->join('source', 'post.source_id = source.id');
$query = $this->db->get();
return $query->result();
3 回答
你可以这样做:
表 . *表示您需要该表中的所有字段 .
将
$this->db->select('*');
更改为$this->db->select('user.firstname, user.lastname');
您可以在选择中定义:
看看这个答案https://stackoverflow.com/a/15402766/1897484