If there are the following forms of SQL:
Select A. *, B.a mount
From A left join (
Select from ame, sum (da mount) as the amount the from C inner join D on C.i D=D.m ain_id group by citigroup ame
B) on A.n ame=B.n ame the where...
To ask you, is there any way to make A connection B index can go?
CodePudding user response:
reference ZJCXC - personal WeChat public, named to ask, is there a way to CodePudding user response:
You can connect C table first, then connect D table, but don't know the reason why you by connection on the left is A and C incomplete or C and D do not completely match, can't give you rewrite the SQL, But this kind of query is certainly can be rewritten into two connections CodePudding user response:
refer to the second floor will respond to the heavy rain: you can connection table C first, then connect D table, but don't know the reason why you by connection on the left is A and C incomplete or C and D do not completely match, can't give you rewrite the SQL, But this query is certainly can be rewritten into two connected I need group in sum, it is just my simplified, and the actual C, D association also requires the value of the other, if you don't rewrite A and B can't use the index associated CodePudding user response:
Mysql outer have the primary key index, index, or not to walk; Is you the where condition, if is A primary key index after go indexes; You can test verify You can refer to the article: https://blog.csdn.net/dgutliangxuan/article/details/87997660 CodePudding user response:
Can walk index, to see what is the condition where A Name and the Name of B there is an index, index Name this will go