[SQL] Table A plurality of fields, one field associated Description Table B

Question: Name the query allocation of resources, consultant name

Crm resource table

Resource id, assigned person id, id consultant

User table user

User id, the user name

Solution:

SELECT 
  crm.id,
  user1.name,
  user2.name 
FROM
  crm 
  LEFT JOIN user1 
    ON crm.blind_id = user1.id 
  LEFT JOIN user2 
    ON crm.work_id = user2.id 

 

Guess you like

Origin www.cnblogs.com/87060524test/p/11209284.html