joining the same table twice on different columns

后端 未结 4 1969

I\'ve got a user table and a complaint table.

The complaint table has the following structure:

[opened_by]   [         


        
4条回答
  •  广开言路
    2020-12-05 12:13

    SELECT 
         complaint.complaint_text, 
         A.username, 
         B.username
    FROM 
         complaint 
         LEFT JOIN user A ON A.user_id=complaint.opened_by 
         LEFT JOIN user B ON B.user_id=complaint.closed_by
    

提交回复
热议问题