这是我的查询
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="section group">
<div class="left-nav col span_1_of_2_">
<h2 class="leftnav-title">Support</h2>
<div>
<a class="link-leftbar" href="www.test.com/support/manuals">
<span>Manuals</span>
</a>
<a class="link-leftbar" href="www.test.com/support/international">
<span>International</span>
</a>
<a class="link-leftbar" href="www.test.com/support/tracking">
<span>Tracking</span>
</a>
<a class="link-leftbar" href="www.test.com/support/contacts">
<span>Contacts</span>
</a>
<a class="link-leftbar" href="www.test.com/support/security">
<span>Security</span>
</a>
<a class="link-leftbar" href="www.test.com/support/registration">
<span>Registration</span>
</a>
<a class="link-leftbar" href="www.test.com/support/policy">
<span>Policy</span>
</a>
<a class="link-leftbar" href="www.test.com/support/troubleshooting">
<span>Troubleshooting</span>
</a>
<a class="link-leftbar" href="www.test.com/support/promotions">
<span>Promotions</span>
</a>
<a class="link-leftbar" href="www.test.com/support/shipping">
<span>Shipping</span>
</a>
<a class="link-leftbar" href="www.test.com/support/terms">
<span>Terms</span>
</a>
<a class="link-leftbar" href="www.test.com/support/claim">
<span>Claim</span>
</a>
</div>
</div>
</div>
UPDATE
`product_pricing`
SET `formula_id`= '2'
WHERE 1
如何将SELECT查询与更新查询合并?
我只需要更新具有SELECT
product_pricing.id,
product_pricing.formula_id,
product_pricing.vat_calculated,
products_ids.id,
products_ids.link_id,
product_attributes.fty_id,
product_attributes.size_id,
product_sizes.size_id,
product_sizes.wheel
FROM product_pricing
LEFT JOIN products_ids ON product_pricing.id = products_ids.id
LEFT JOIN product_attributes ON products_ids.link_id = product_attributes.fty_id
LEFT JOIN product_sizes ON product_attributes.size_id = product_sizes.size_id
WHERE
product_sizes.wheel = '13'
的产品,但是要获取此信息,我需要一些左联接。
答案 0 :(得分:1)
您可以将此更新与LEFT JOIN和Where一起使用
update product_pricing
LEFT JOIN products_ids ON product_pricing.id = products_ids.id
LEFT JOIN product_attributes ON products_ids.link_id = product_attributes.fty_id
LEFT JOIN product_sizes ON product_attributes.size_id = product_sizes.size_id
SET product_pricing.formula_id= '2'
WHERE
product_sizes.wheel = '13'
答案 1 :(得分:0)
尝试
update product_pricing p
LEFT JOIN products_ids pi ON p.id = pi.id
LEFT JOIN product_attributes pa ON pi.link_id = pa.fty_id
LEFT JOIN product_sizes ps ON pa.size_id = ps.size_id
SET p.formula_id= '2'
WHERE
ps.wheel = '13'
答案 2 :(得分:0)
我认为这里需要INNER JOIN
:
update product_pricing
INNER JOIN products_ids ON product_pricing.id = products_ids.id
INNER JOIN product_attributes ON products_ids.link_id = product_attributes.fty_id
INNER JOIN product_sizes ON product_attributes.size_id = product_sizes.size_id
SET product_pricing.formula_id= '2'
WHERE product_sizes.wheel = '13'