I have 3 tables in a MySQL database
user
user_id, (PK)
email
agreement_user
agreement_user_id, (PK)
user_id, (FK user.user_id)
details
contract
contract_id, (PK)
agreement_user_id, (FK agreement_user.agreement_user_id)
details
What should be the query to get contract.details and user.email given a contract_id
>Solution :
maybe you can try
SELECT contract.details, user.email FROM contract
INNER JOIN agreement_user ON contract.agreement_user_id = agreement_user.agreement_user_id
INNER JOIN user ON agreement_user.user_id = user.user_id
WHERE contract.contract_id = @yourSpecificId;