Column 'id_siswa' in where clause is ambiguous
SELECT * FROM `siswa` `a`
LEFT JOIN `pembayaran_spp` `b` ON `b`.`id_siswa`=`a`.`id_siswa`
WHERE `id_siswa` = '7%E2%80%8B'
I have 2 table.
1.table 'siswa' structure(id_siswa,nama_siswa,id_tahun_masuk)
2.table 'pembayaran_spp'-> structure(id_pembayaran,id_siswa,jml_pembayaran,id_tahun,date)
I want to show data 'pembayaran_spp' by id_siswa. so when i click detail on 'siswa', data 'pembayaran' is showed by id_siswa.
function detailtagihan($id_siswa)
{
$data['siswa'] = $this->M_keuangan->tagihansiswa($id_siswa);
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('keuangan/v_detailtagihan',$data);
$this->load->view('template/footer');
}
function tagihansiswa($id_siswa)
{
//$data = array('id_siswa' => $id_siswa );
$this->db->select('*');
$this->db->from('siswa a');
$this->db->join('pembayaran_spp b','b.id_siswa=a.id_siswa', 'left');
$this->db->where('id_siswa',$id_siswa);
$query = $this->db->get();
if($query->num_rows()>0)
return $query->result();
}
答案 0 :(得分:0)
您应该在where子句中提及要使用列id_siswa
的表。由于两个表都有一个具有相同名称的列,因此您收到此错误。
如果您想使用siswa
,请在您的where条件中写下a.id_siswa
如果您想使用pembayaran_spp
,那么请在b.id_siswa
。