Can you do a For Each Row loop using MySQL?

后端 未结 3 1187
耶瑟儿~
耶瑟儿~ 2021-01-01 12:15

My question is related to the answer found in this post by user Consultuning on Oct 22 \'09 at 18:31: mysql query to dynamically convert row data to columns

3条回答
  •  庸人自扰
    2021-01-01 12:57

    Not a for each exactly, but you can do nested SQL

    SELECT 
        distinct a.ID, 
        a.col2, 
        (SELECT 
            SUM(b.size) 
        FROM 
            tableb b 
        WHERE 
            b.id = a.col3)
    FROM
        tablea a
    

提交回复
热议问题