Home > database >  Questions about the join and the efficiency of the subquery
Questions about the join and the efficiency of the subquery

Time:09-19

There is now a simple scenario:
There are two tables in the database, table the user for the user (the attribute id name) and the user request userinter (the attribute id userid system, including userid associated since the id of the user table),

Now I want to check out each user intention:
The join example:
 select Anderson d, a.n ame, b.i nter the from user a join userinter b on Anderson, d=b.u serid; 

The subquery example:
 select Anderson d, a.n ame, (select b.i nter the from userinter b where b.i d=Anderson, d) as yx the from user having a yx is not null; 


This two ways to query the result is the same, online said at the time of data recommended in the join rather than the subquery, reason is that the subquery is dependent on the outer query, for each of the outer query to perform again the subquery,

Then the join is how to check?

Hope each netizen expert to help solve, thank!

CodePudding user response:

According to the relationship between the key table fields, link query, general advice not to use sub queries

CodePudding user response:

This problem according to the actual business scenarios, data structures, existing indexes, the amount of data in the table decision, cannot treat as the same,

CodePudding user response:

reference 1/f, you are a little KS reply:
, according to the relationship between the key table fields link query, general advice not to use the subquery

Thank you for your reply

CodePudding user response:

refer to the second floor AHUA1001 response:
this problem according to the actual business scenarios, data structures, existing indexes, the amount of the data in the table, cannot treat as the same,

Thank you for your reply
  • Related