仅当id在2个表而不是第3个表上匹配时,才将列从一个表更新到另一个表

时间:2018-02-18 03:43:36

标签: mysql

我有3张桌子A B C.

|--------A-------|
| ID   | Price   |
|------|---------|
|  1   | 0       |
|----------------|
|  2   | 0       |
|------|---------|
|  3   | 0       |
|----------------|
|  4   | 0       |
|----------------|

|--------B-------|
| ID   | Price   |
|------|---------|
|  1   | 2.00    |
|----------------|
|  2   | 5.00    |
|------|---------|
|  3   | 3.00    |
|----------------|
|  4   | 1.00       |
|----------------|

|--------C-------|
| ID   | Price   |
|------|---------|
|  5   | 2.00    |
|----------------|
|  6   | 5.00    |
|------|---------|
|  1   | 2.00    |
|----------------|
|  2   | 5.00    |
|----------------|

我想将B.price复制到A.price只有当B.ID没有在C.ID中激活时。如果是A.ID(3加4)。结果看起来像这样

|--------A-------|
| ID   | Price   |
|------|---------|
|  1   | 0       |
|----------------|
|  2   | 0       |
|------|---------|
|  3   | 3.00    |
|----------------|
|  4   | 1.00    |
|----------------|

1 个答案:

答案 0 :(得分:2)

使用更新联接。下面的查询执行A和B表之间的内部联接,因为此处的匹配是进行更新所必需的。然后,我们对C表进行第二次左连接,extension UIView{ func rotate() { let rotation : CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z") rotation.toValue = NSNumber(double: M_PI * 2) rotation.duration = 1 rotation.cumulative = true rotation.repeatCount = FLT_MAX self.layer.addAnimation(rotation, forKey: "rotationAnimation") } } 子句限制B和C表之间的匹配。

WHERE
相关问题