Continue to ask the mysql Query statement: multi-table joint query. how can I limit the specific where or limit on the right table if there is a corresponding record? otherwise, no limit is imposed.

Source: Internet
Author: User
Continue to consult the mysql Query statement: multi-table joint query, how to limit the specific where limit or limit if the table on the right has a corresponding record, otherwise, no restrictions are imposed, such as table 6 joint queries. Currently, a & nbsp; left & nbsp; join & nbsp; B & nbsp; left & nbsp; join & nbsp; c & nbsp; left & nbsp; join & nbsp; d & nbsp; left & nbsp continue to consult mysql Query statement: multi-table joint query, how to restrict tables on the right to specific where or limit restrictions if there is a corresponding record, otherwise no restrictions
Example

6 Table join queries. Currently, a left join B left join c left join d left join e left join f is used.

To ensure that each record in Table a can only find one corresponding record in the bcedf table, some conditions must be added.

However, after a restriction such as where f. aaa in (0, 1, 2, 3) is added, all query results have corresponding records in table f.

How can I modify the statement if no corresponding record exists in table f?


In addition, if another question is asked, even if such a condition is added, the becdf table still has multiple records. can I limit this SQL statement to only query the latest one for table f, to prevent repeated records in Table a from appearing in the results
------ Solution ----------------------
A query result needs to be connected through 6 tables. it should be said that there is a problem with your table design.
You can press the join key to create several transition tables to reduce the impact between tables.
------ Solution ----------------------
6. what is the Cartesian product generated for table queries? I am stuck.
------ Solution ----------------------
1. as I have mentioned above, a transitional table is generated before querying a transitional table.
2. use a view to convert an unreasonable design into a rational design, and query the view.

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.