![](/img/trans.png)
[英]Find values in one column that share same value in different column without knowing the 2nd cols value
[英]Updating a Column with the minimum value of that same column depending on a 2nd column
這是我的桌子:
Col_1 | Col_2
1 | abcd
2 | abcd
3 | edcr
4 | yhns
5 | edcr
我想更新Col_1以返回以下內容
Col_1 | Col_2
1 | abcd
1 | abcd
3 | edcr
4 | yhns
3 | edcr
我正在嘗試使用UPDATE
和GROUP BY
進行此操作,但似乎無法弄清楚。 任何幫助,將不勝感激。
謝謝
嘗試這個
UPDATE table1 t1 JOIN table1 t2 ON t1.Col_2 = t2.Col_2 SET t1.Col_1 = t2.Col_1;
注意:確保您的Col_1不是主鍵
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.