1

数据库A包含表X

数据库B包含表Y and Z

A.X包含字段order_numberdude

B.Y包含字段orderdude_number B.Z包含字段other_dude_numberdude_type

我想A.X.dude更新到B.Y.dude_number基于:(B.Y.order = A.X.order_number) AND ((B.Z.other_dude_number = B.Y.dude_number) AND (B.Z.dude_type = 6))

我已经抽出两个小时的 mySQL 查询来尝试让它工作。我几乎可以肯定我在某个地方需要一个UNION,但我对UNION还不够熟悉,无法使用它。

4

1 回答 1

5
UPDATE A.X
  JOIN B.Y ON Y.`order` = X.order_number
  JOIN B.Z ON Z.other_dude_number = Y.dude_number
SET      X.dude = Y.dude_number
WHERE    Z.dude_type = 6
于 2012-12-05T22:19:44.907 回答