我正在使用MySQL Workbench:
起点:
ParcelID | Address | 44 | 街xxxx |
---|---|
32 | 街yyyy |
空 | |
空 | |
12 | 空 |
12 | 街睡眠 |
一种选择是移动连接内部的条件,并将address2直接设置为address1,如下所示:
UPDATE tab t1
INNER JOIN tab t2
ON t1.ParcelID = t2.ParcelID
AND (t1.Address = '' OR t1.Address IS NULL)
AND NOT (t2.Address = '' OR t2.Address IS NULL)
SET t1.Address = t2.Address;
演示。