table1:
ID | SKU | Images
------------------
1 | 1502 | Link1
2 | 1852 | Link2
3 | 1745 | Link3
table2:
ID | Product | MainLink
------------------------
1 | 1501 | Link1
2 | 1502 | Link1
3 | 1852 | Link2
3 | 1745 | Link3
我试图从table1中更新SKU,而table2
中每个主链接的最低值结果是:
table1:
ID | SKU | Images
------------------
1 | 1501 | Link1
2 | 1852 | Link2
3 | 1745 | Link3
这是我到目前为止的查询
UPDATE Table1 t1 JOIN Table2 t2 ON t1.Images = t2.MainLink SET t1.SKU = t2.Product
尝试以这种方式:
UPDATE Table1 t1
JOIN (SELECT MIN(Product) Product, MainLink
FROM Table2 GROUP BY Table2.MainLink
) t2 ON t1.Images = t2.MainLink SET t1.SKU = t2.Product