来自另一个表的MySQL更新字段已分组

时间:2013-11-25 05:32:02

标签: mysql select join

这是我的选择查询:

SELECT
    sap.stat_ap_id, ju.mu, SUM(ju.ju_amount_p) total_amount_p, SUM(ju.ju_amount) konversi_idr
FROM 
    t_stat_ap sap
    LEFT JOIN t_ju ju ON sap.ju_session_id_ap = ju.ju_session_id AND ju.post_type = 't_statement' AND ju.ju_stat > '0'
    LEFT JOIN t_acc_level3 as v3 ON v3.level3_id = ju.ju_akun
    LEFT JOIN t_acc_level2 as v2 ON v2.level2_id = v3.level2_id
    LEFT JOIN t_acc_level1 as v1 ON v1.level1_id = v2.level1_id
WHERE 1
    AND ju.ju_stat > '0'
    AND v1.level1_id = '2'
GROUP BY sap.stat_ap_id, ju.mu

是否可以更新每一行t_stat_ap表???

1 个答案:

答案 0 :(得分:0)

是的,您可以在foreach循环中更新查询,直到表中存在的行数。 您编写的查询仅从这些表中选择(过滤)数据。