我想将两个GROUP BY结果添加到另一个表中。我的两个GROUP BY结果是:
我希望将此结果插入到新表或另一个表中。
这是我到目前为止所拥有的:
public function addMPL(){
$query = "INSERT INTO tbl_mpl(tConsumption)
select MONTHNAME(date), SUM(amount)
FROM tbl_income
GROUP BY YEAR(date), MONTH(date)";
}
tbl_income =每月收入(表)
$query = "INSERT INTO tbl_mpl(tConsumption) select MONTHNAME(date), SUM(amount) FROM tbl_income GROUP BY YEAR(date), MONTH(date)";
正确的方法是什么?