public function getIncomeBranches()
{
return
$this->db->select('t1.subject_name, t2.payment_grand, t2,.payment_date, t3.level_id')
->join('groups AS t3', 't1.subject_id = t3.group_id', 'left')
->join('payments AS t2', 't1.subject_id = t2.payment_id')
->group_by('t1.subject_id')
->get("subjects AS t1")->result();
}
错误号码:1064
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近'
t3
。level_id
FROMsubjects
ASt1
LEFT JOINgroups
ASt3
ONt1
。“sub'在第1行
SELECT `t1`.`subject_name`, `t2`.`payment_grand`, `t2`, .`payment_date`, `t3`.`level_id` FROM `subjects` AS `t1` LEFT JOIN `groups` AS `t3` ON `t1`.`subject_id` = `t3`.`group_id` JOIN `payments` AS `t2` ON `t1`.`subject_id` = `t2`.`payment_id` GROUP BY `t1`.`subject_id`
文件名: d:/www/domains/uzdev/taraqqiyot/application/models/Dashboard_model.php
行号:69
我想通过ID来记录主题并显示该主题的所有付款。
答案 0 :(得分:3)
查询,
中的不受欢迎的t2,.payment_date,
只是将其从第一行删除
这将是
$this->db->select('t1.subject_name, t2.payment_grand, t2.payment_date, t3.level_id')
->join('groups AS t3', 't1.subject_id = t3.group_id', 'left')
->join('payments AS t2', 't1.subject_id = t2.payment_id')
->group_by('t1.subject_id')
->get("subjects AS t1")->result();
答案 1 :(得分:0)
你的错误 - > t2,.payment_date,
public function getIncomeBranches()
{
return
$this->db->select('t1.subject_name, t2.payment_grand, t2.payment_date, t3.level_id')
->join('groups AS t3', 't1.subject_id = t3.group_id', 'left')
->join('payments AS t2', 't1.subject_id = t2.payment_id')
->group_by('t1.subject_id')
->get("subjects AS t1")->result();
}
答案 2 :(得分:0)
t2,.payment_date
至t2.payment_date
以及
$this->db->select('t1.subject_name, t2.payment_grand, t2.payment_date, t3.level_id')
->join('groups AS t3', 't1.subject_id = t3.group_id', 'left')
->join('payments AS t2', 't1.subject_id = t2.payment_id')
->group_by('t1.subject_id')
->get("subjects AS t1")->result();
加入时,语法就是这个,
$this->db->join("table1","table1.id = table2.id");
如果正确,请检查第二次加入。