从 table 中的值更新列空白
updating a column blanks from values within the table
我想用列中的邮政编码更新字段为空的 table 列,因为两行的名称字段相同。
所以运输 zip 空白需要填写名称相同的相同运输 zip。
谢谢
The attached is the table screenshot
您没有提供实际的 table 名称。我将使用 table_name
作为向您展示该做什么的方式。我使用了 table_name 两次,所以每次我都给它一个 别名 (m
& f
)。这样我们就可以进行比较
回答慢
UPDATE table_name m
SET m.shipping_zip =
(SELECT f.shipping_zip
FROM table_name f
WHERE f.Name=m.Name and f.shipping_zip<>'')
WHERE m.shipping_zip = '';
快速回答(但未经测试)
UPDATE table_name m, table_name f
SET m.shipping_zip = f.shipping_zip
WHERE m.Name=f.Name AND m.shipping_zip='' AND f.shipping_zip<>'';
可以这样做
update `table` t, (select * from `table`
where shipping_zip is not null and shipping_zip != '')q
set t.shipping_zip = q.shipping_zip
where t.Name = q.Name;
我想用列中的邮政编码更新字段为空的 table 列,因为两行的名称字段相同。
所以运输 zip 空白需要填写名称相同的相同运输 zip。
谢谢
The attached is the table screenshot
您没有提供实际的 table 名称。我将使用 table_name
作为向您展示该做什么的方式。我使用了 table_name 两次,所以每次我都给它一个 别名 (m
& f
)。这样我们就可以进行比较
回答慢
UPDATE table_name m
SET m.shipping_zip =
(SELECT f.shipping_zip
FROM table_name f
WHERE f.Name=m.Name and f.shipping_zip<>'')
WHERE m.shipping_zip = '';
快速回答(但未经测试)
UPDATE table_name m, table_name f
SET m.shipping_zip = f.shipping_zip
WHERE m.Name=f.Name AND m.shipping_zip='' AND f.shipping_zip<>'';
可以这样做
update `table` t, (select * from `table`
where shipping_zip is not null and shipping_zip != '')q
set t.shipping_zip = q.shipping_zip
where t.Name = q.Name;