How to change rows in a table based on other table rows in mysql?
Posted
by understack
on Stack Overflow
See other posts from Stack Overflow
or by understack
Published on 2010-04-05T22:15:23Z
Indexed on
2010/04/05
22:23 UTC
Read the original article
Hit count: 243
I've a table which has 3 columns: id, a_id and b_id.
Suppose rows are like this:
1, a1, b1
2, a1, b2
3, a1, b3
4, a2, b4
5, a2, b5
6, a2, b6
I want to convert it to
1, a1, b1
2, a1, b1
3, a1, b1
4, a2, b4
5, a2, b4
6, a2, b4
So I want to make all the b_id corresponding to a_id same, and equal to the one which is found first. How can I do this? For simplicity, I've removed other columns from table. So please ignore row duplication here.
© Stack Overflow or respective owner