Can an SQL statement add, update, or delete two tables at the same time?

Source: Internet
Author: User
1: Can an SQL statement add, update, or delete two tables at the same time? 2: can a single SQL statement operate on multiple tables at the same time only select statements? 3: What if multiple new update/delete statements are separated by semicolons? 4: If multiple select statements are used with semicolons... 1: One SQL statement can be used to add, update, or delete two tables at the same time?

2: can a single SQL statement operate on multiple tables at the same time only select statements?

3: What if multiple add, update, or delete statements are separated by semicolons?

4: What if multiple select statements are separated by semicolons?

Reply content:

1: Can an SQL statement add, update, or delete two tables at the same time?

2: can a single SQL statement operate on multiple tables at the same time only select statements?

3: What if multiple add, update, or delete statements are separated by semicolons?

4: What if multiple select statements are separated by semicolons?

1: Can an SQL statement add, update, or delete two tables at the same time?

No. Of course, if you use;Separating two SQL statements can be executed in the past .. But in a strict sense, it's not one.

2: can a single SQL statement operate on multiple tables at the same time only select statements?

Yes. Let's see what multi-Table operations you are referring to. If multiple tables have the same structure. UseUnionMerge multiple table results. There are also subqueries, which are also called select multiple tables ..

3: What if multiple add, update, or delete statements are separated by semicolons?

Of course. It is equivalent to executing multiple statements .. However, some engines and frameworks will forcibly filter this type to prevent injection. Otherwise, someone inserts a semicolon in the middle of the query statement to execute any statements he wants to execute.

4: What if multiple select statements are separated by semicolons?

This is also based on the engine. Most of them will return the results of your request in sequence. Some Frameworks return the first and some return the last one. Based on the framework, we recommend that you directly write a simple SQL statement for testing ..

Ps. Generally, multiple SQL statements are not allowed at a time. Otherwise it would be really dangerous...

Only answer question 1.

Does the view count?
MySQL supports a "View", which can make multiple tables into one view. The addition, deletion, modification, and query operations on this view can affect multiple tables.
View description in MySQL 5.7: http://dev.mysql.com/doc/refman/5.7/en/views.html

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.