joining the same table twice on different columns

后端 未结 4 1962

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

The complaint table has the following structure:

[opened_by]   [         


        
4条回答
  •  孤城傲影
    2020-12-05 12:10

    Use this query:

    SELECT opener.username as opened_by, complaint.complaint_text, closer.username as closed_by
    FROM complaint
    LEFT JOIN user as opener ON opener.user_id=complaint.opened_by
    LEFT JOIN user as closer ON closer.user_id=complaint.closed_by
    

提交回复
热议问题