用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1587|回复: 4
收起左侧

[HELP] 求教:两个数据表,各有查询条件,JION怎么写呢,先感谢~

[复制链接]
发表于 2014-1-9 16:12:58 | 显示全部楼层 |阅读模式
      $this->db->where('user_id', $user_id);
      $this->db->select('star_id');
      $query = $this->db->get('tbl_star_user_light');
          
          
          $this->db->where('user_id', $user_id);
      $this->db->or_where('parent_id',$user_id);
          $this->db->select('star_id');
      $query = $this->db->get('tbl_star');


取两个表格star_id的交集,返回一个数组。
发表于 2014-1-9 20:12:19 | 显示全部楼层
$this->db->from('tbl_star_user_light')->join('tbl_start', 'sql条件')->get()->result_array();
 楼主| 发表于 2014-1-10 08:32:09 | 显示全部楼层
可以用where、select、get,代替sql条件么?

就是不知道怎么写这个sql哦~~
 楼主| 发表于 2014-1-10 12:04:39 | 显示全部楼层
哪位大侠帮忙回答一下呀~~~~
发表于 2014-1-10 14:25:15 | 显示全部楼层
select * from table_a A left join table_b B on A.x = B.x where A.y = ? and B.z = ?

本版积分规则