to ask a question, (MySQL) table A has code_name,code_id,code_field at the end, and table B of another table has many attributes, such as nationality, place of origin, and so on. The nationality subquery method is select code_name form A table where code_id= B table. GJ _ id and code_field = "gj".
the difficulty encountered now is that the subquery is too slow, and there are other attributes such as place of origin in addition to nationality. If all subqueries are used, it will be estimated for a few minutes at a time. Can we use a contingency table in this case?
is there any good solution?
the writing style is not good. You can look directly at the following code to see how to optimize
.select
B.code_name,C.code_name
FROM
A
JOIN B
ON
B.code_id = A.GJ AND B.field_name = "GJ"
JOIN B as C
ON
C.code_id = A.MZ AND C.field_name = "MZ"
this way of writing nested join is even longer than a subquery. What is the reason for this? if you know it, you can also say ha
.