我有几张表想一次显示一个id。
表A
id | isi a1 | isi a2
表B
id | id | a | isi b1 | isi b2
表C
id | id | a | isi c1 | isi c2
表D
id | id | a | isi d1 | isi d2
表E
id | id | a | isi e1 | isi e2号
我想展示isi B1-E2,在表a中每个表都有I d_a=id。我不知道mysql join,我已经尝试了这段代码

$this->db->select('BaseTbl.id, BaseTbl.tanggal, BaseTbl.atas_nama, BaseTbl.kerugian, BaseTbl.keterangan, BaseTbl.admin, BaseTbl.status');
$this->db->from('data_blacklist as BaseTbl');
$this->db->join('bl_rekening as Rekening, bl_telefon as Telefon, bl_bukti as Bukti, bl_pelapor as Pelapor', 'Rekening.id_blacklist = BaseTbl.id, Telefon.id_blacklist = BaseTbl.id, Bukti.id_blacklist = BaseTbl.id, Pelapor.id_blacklist = BaseTbl.id','left');

但它总是给我
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' bl_telefon as Telefon, bl_bukti as Bukti, bl_pelapor as Pelapor ON `Rekening`.`' at line 3

我现在不知道。知道吗?我用编码器点火

最佳答案

试试这个。必须查询每个表的联接。你不能把它们组合起来

$this->db->select('BaseTbl.id, BaseTbl.tanggal, BaseTbl.atas_nama, BaseTbl.kerugian, BaseTbl.keterangan, BaseTbl.admin, BaseTbl.status');
$this->db->from('data_blacklist as BaseTbl',);
$this->db->join('bl_rekening as Rekening','Rekening.id_blacklist = BaseTbl.id','left');
$this->db->join('bl_telefon as Telefon','Telefon.id_blacklist = BaseTbl.id','left');
$this->db->join('bl_bukti as Bukti','Bukti.id_blacklist = BaseTbl.id','left');
$this->db->join('bl_pelapor as Pelapor','Pelapor.id_blacklist = BaseTbl.id','left');

10-06 15:20