The magic of OUTPUT in isnertdeleteupdate _ MySQL

Source: Internet
Author: User
Inserteddeleted personally understands that two temporary tables are used to store changed datasets and datasets before changes respectively. example: 1. for INSERT, you can reference the inserted table to query the attributes of a new row. insertinto [table name] (a) OUTPUTInser... inserted deleted my personal understanding should be that two temporary tables store the changed dataset and the former one respectively.

Example:

1. for INSERT, you can reference the inserted table to query the attributes of a new row.

Insert into [table name] (a) OUTPUT Inserted. a values ('A ')

2. for DELETE, you can reference the deleted table to query the attributes of the old row.

Delete [table name] OUTPUT deleted. a where links = 'A'

3. for UPDATE, use the deleted table to query the attributes of the updated row before the change. use the inserted table to identify the value of the updated row after the change.

Update [table name] set a = 'B' OUTPUT Inserted. a where a = 'a' (return the modified value)

Update [table name] set a = 'B' OUTPUT deleted. a where a = 'a' (return the value before modification)

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.