这个SQL语句怎么写
select colum1 from table1,table2 where table1.colum1={$id} and table1.colum2=table2.colum1这句用CI怎么做啊
$this->db->select(colum1);
$this->db->from(array('table1','table2'));
$sql = "uid={$id} andtable1.colum2=table2.colum1
$this->db->where($sql);
$data['query'] = $this->db->get();
这样写不行吗 干嘛非要写成那样的,你就直接用sql语句query就好啦 回复 2# ywqbestever
恩,写不出来,最后还是直接SQL写的 $this->db->select(colum1);
$this->db->from('table1');
$this->db->join('table2', 'table1.colum2=table2.colum1');
$this->db->where('uid', $id);
$data['query'] = $this->db->get(); 警告楼主一次,请不要重复发帖,我见到不是一次两次了。 function get_goods_info($cid) {
$this->db->select('colum1');
$this->db->from('table1');
$this->db->where('uid', $id);
$this->db->join('table2', 'table1.colum2=table2.colum1', 'left');
$query = $this->db->get();
return $query->result();
} ci的sql查询 ,老感觉很蹩脚.
页:
[1]