I'm trying to clear some data in MySQL, and I'm not sure how the most efficient way to fix the following. I have three columns A, B and C. They often take the same value. If A and B are the same or C matches, then I want, if possible, to populate the other option with NULL. B and C do not affect the value for A. For example:
-------------------
|A |B |C |
-------------------
|1 |2 |3 |
|1 |2 |NULL |
|2 |5 |8 |
|2 |NULL |8 |
|3 |NULL |9 |
|3 |NULL |NULL |
-------------------
In the line of example 2 above, column C should be filled with 3 and line 4, column B should be 5. When I have only two options, we then fill in accordingly. Therefore row 6, column C must be 9, and row 5 of column B and column 6 of row 6 remain NULL. How can I write a script to solve this problem, so that if B or C is not NULL, we fill it with the other values ββin the table? Thank you
source
share