Continue to consult the mysql Query statement: multi-table joint query, how to limit the right table if there is a corresponding record, then add a specific where limit or limit, otherwise there is no limit, as shown in the question
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
Reply to discussion (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.
6. what is the Cartesian product generated for table queries? I am stuck.
Because you want to generate real-time reports... so there are many businesses involved...
Of course, this is definitely a problem with the preliminary design, but there is no way to redo it now.
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.
F. id is null