Can an SQL statement add, update, and delete two tables at a time?

Source: Internet
Author: User
1: An SQL statement can be added to the two tables at the same time, update, delete operations?

2: Can a SQL statement have only SELECT statements for multiple table operations at the same time?

3: What if multiple Add/update/delete action statements are separated by semicolons?

4: What happens if multiple SELECT statements are separated using semicolons?

Reply content:

1: An SQL statement can be added to the two tables at the same time, update, delete operations?

2: Can a SQL statement have only SELECT statements for multiple table operations at the same time?

3: What if multiple Add/update/delete action statements are separated by semicolons?

4: What happens if multiple SELECT statements are separated using semicolons?

1: An SQL statement can be added to the two tables at the same time, update, delete operations?

No, of course, if you ; pass a two-piece SQL passed in the past can be executed. But that's strictly not the point.

2: Can a SQL statement have only SELECT statements for multiple table operations at the same time?

Yes, look what you're referring to. Multiple table operations, if more than one structure of the table. Use Union to combine multiple table results. There are also sub-queries, also considered as select multiple tables.

3: What if multiple Add/update/delete action statements are separated by semicolons?

Of course you can pull. Equivalent to executing more than one statement: Some engines and frameworks, however, are forced to filter this type to prevent them from being injected. Otherwise, someone inserts a semicolon in the middle of the query statement, so you can execute any statement that he wants to execute.

4: What happens if multiple SELECT statements are separated using semicolons?

This also looks at the engine, most of which will return the result of your request in turn. There are also frameworks that return the first one, and some return the last. According to the framework suggest you write a simple SQL to do the next test will know.

PS. It is generally not allowed to have multiple SQL at once. Otherwise it's really dangerous ...

Answer only question 1.

Does the view count?
MySQL supports a thing called "view" that can make multiple tables into a single view. Adding or deleting this view can affect multiple tables.
Description of the view 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.