MariaDB 10.3 Solved the update that the update cannot query in the same table as the same table

Source: Internet
Author: User

MariaDB 10.3 Resolved the update cannot be queried in the same table as updates to the same table, and supports the updatean UPDATE statement with the same source and destination.


See the case directly below

CREATE TABLE T1 (c1 int, c2 int), INSERT into T1 VALUES (10,10), (20,20); UPDATE T1 SET c1=c1+1 WHERE c2= (SELECT MAX (C2) from T1);


MySQL5.7 Direct Error



MySQL 8.0 Direct Error



MariaDB 10.3 Update Successful



MySQL can only rewrite the SQL implementation at this time, that is, the MAX statement allows it to produce a derivative table.

UPDATE T1 A, (SELECT MAX (C2) as m_c2 from T1) as B SET a.c1=a.c1+1 WHERE a.c2=b.m_c2;




MariaDB 10.3 Solved the update that the update cannot query in the same table as the same table

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.