SELECT DISTINCT values and INSERT INTO table

后端 未结 4 2051
独厮守ぢ
独厮守ぢ 2021-01-18 15:50

I want to take a column with values that repeat multiple times and get that value only once and store it for later use, but at the same time I would like to get another valu

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-18 16:18

    You can use INSERT INTO... SELECT statement on this,

    INSERT INTO tableName (A, B, C)
    SELECT A, B, MAX(C) + 1
    FROM tableName
    GROUP BY A, B
    
    • SQLFiddle Demo

提交回复
热议问题