从两个表中的CodeIgniter中左JOIN加入,两个值要显示



表1包含定时套筒,表2包含类别的名称。我需要类别名称和时间安排才能显示出从两个表格中显示ID的左JOIN,如何可能?

在以下查询

以下尝试
select * from table1 left join table2 on table1.id=table2.id

在CI

$this->db->select('*');
$this->db->from('table1');
$this->db->join('table2 ', 'table1.id=table2.id', 'left');
$query = $this->db->get();
Use this code which will help to get the data from the two tables and getting the two values from both the tables:
<?PHP
 $this->db->select('t1.name, t2.desc')
 ->from('table_first as t1')
 ->where('t1.id', $id)
 ->join('table_second as t2', 't1.id = t2.id', 'LEFT')
 ->get();
?>

最新更新