我有两个表,我的数据库名是成员
loanapplications
id是:loan_id
列:loantype, contact_number.. etc
users
id为:id
我如何离开加入或其他种类加入这两个以便我可以显示具有相同贷款ID和id的用户的loantype和联系人号码?
我尝试了这个并且它没有工作:
select * from loanapplications l
JOIN users u ON l.loan_id =u.id
答案 0 :(得分:0)
loanapplications
表应该有一个列,说明申请贷款的用户,我将其称为applicant_id
。然后查询将是:
SELECT *
FROM loanapplications l
JOIN users u ON l.applicant_id = u.id