我有这样的模特
public function lihatgajiharian($id,$tglitung){
$status='m';
$this->db->select('count( tgl ) AS total, absen.id, pegawai.nama, pegawai.bagian, pegawai.bagian, pegawai.tglmasuk, gaji.jenis_gaji, gaji.jumlah, gajiharian.id_gajiharian, gajiharian.status, gajiharian.tgldigaji,
(CASE WHEN (weekday( tgl ) <=3) THEN date( tgl + INTERVAL( 3 - weekday( tgl ) )DAY )
ELSE date( tgl + INTERVAL( 3 +7 - weekday( tgl ) )DAY )END) AS tglitung');
$this->db->from('absen');
$this->db->join('pegawai', 'pegawai.id = absen.id');
$this->db->join('gaji', 'gaji.id = pegawai.id');
$this->db->join('gajiharian', 'gajiharian.= absen.id','left');
$this->db->where('absen.id',$id);
$this->db->where('absen.status',$status);
$this->db->group_by('absen.id');
$this->db->group_by('tglitung');
$this->db->having('tglitung', $tglitung);
$query = $this->db->get();
return $query->row();
并出现错误,
错误号码:1064
您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以便使用“
.
idWHERE
absen.
id= '15' AND
absen {{1}附近的正确语法} {状态{1}} ABS&#39;在第6行 但如果我尝试在这样的SQL中运行查询
答案 0 :(得分:1)
检查第三次加入$status='m';
$this->db->select('count( tgl ) AS total, absen.id, pegawai.nama, pegawai.bagian, pegawai.bagian, pegawai.tglmasuk, gaji.jenis_gaji, gaji.jumlah, gajiharian.id_gajiharian, gajiharian.status, gajiharian.tgldigaji,
(CASE WHEN (weekday( tgl ) <=3) THEN date( tgl + INTERVAL( 3 - weekday( tgl ) )DAY )
ELSE date( tgl + INTERVAL( 3 +7 - weekday( tgl ) )DAY )END) AS tglitung');
$this->db->from('absen');
$this->db->join('pegawai', 'pegawai.id = absen.id');
$this->db->join('gaji', 'gaji.id = pegawai.id');
$this->db->join('gajiharian', 'gajiharian.column= absen.id','left'); //in this line problem occurs
$this->db->where('absen.id',$id);
$this->db->where('absen.status',$status);
$this->db->group_by('absen.id');
$this->db->group_by('tglitung');
$this->db->having('tglitung', $tglitung);
$query = $this->db->get();
return $query->row();
附近你只放了一个点而不是列添加它,问题就会解决...
{{1}}