Sub-queries and aliases cannot be used in Mysql,update

Source: Internet
Author: User
Tags aliases

Update Po_header

Set Total_fee = (
Select Ip.payment-ip.post_fee
From Po_header IP
where ip.po_header_id = po_header_id
)
where trade_id in (
Select trade_id from trade where shop_id = 2094;

The above update script needs to be done in MySQL by Innerjoin

Update Po_header p1 INNER JOIN
(select po_header_id, (payment-post_fee) Total_fee
From Po_header) IP on
ip.po_header_id = p1.po_header_id
Set P1.total_fee = Ip.total_fee
where trade_id in (
Select trade_id from trade where shop_id = 2094
)

Sub-queries and aliases cannot be used in Mysql,update

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.