doubts about subqueries and table join queries
there are two tables, user (user) and user_dictionary (user Dictionary), and then my colleague struggles with me with a problem. Forgive me for this scum who doesn"t know
.related codes
user: industry, occupation, grade, etc. Multiple selective attributes
user_dictionary: type, value, value name
now there are two sql, which is more efficient
1:
select u.farmer,
(select ud. Value name from user_dictionary ud where ud. Type = "Industry" and ud. Value = u. Industry) as" Industry name",
(select ud. Value name from user_dictionary ud where ud. Type = "occupation" and ud. Value = u. Occupation) as" occupation name",
(select ud. Value name from user_dictionary ud where ud. Type = "level" and ud. Value = u. As" level name",
from user u
2:
select u.handwriting ud1. Value name, ud2. Value name, ud3. Value name
from user u
left join user_dictionary ud1 on u. Industry = "set industry number" and ud1. Value = u. Industry
left join user_dictionary ud2 on u. Occupation = "set occupation number" and ud1. Value = u. Occupation
left join user_dictionary ud3 on u. Level = "set level number" and ud1. Value = u. Grade