我有一个带有adjustable_id | adjustable_type | order_id列的表adjustable_id | adjustable_type | order_id
order_id是填充值的目标列,该值应该来自另一个具有order_id列的表line_items。adjustable_id (int) and _type (varchar)引用该表。
table: adjustments
id | adjustable_id | adjustable_type | order_id
------------------------------------------------
100 | 1 | line_item | NULL
101 | 2 | line_item | NULL
table: line_items
id | order_id | other | columns
--------------------------------
1 | 10 | bla | bla
2 | 20 | bla | bla在上面的例子中,我想我需要一个连接查询来使用值10更新adjustments.order_id第一行,用20更新其他行的第二行,等等。
如果查找失败,我需要删除无效的adjustments行,它们没有对应的line_items。
发布于 2015-03-18 11:40:03
从A.name=B.name A到A.id=B.id上的table2 B中更新集合table2
https://stackoverflow.com/questions/29120675
复制相似问题