Samuel Cotinguey Jr. Samuel Cotinguey Jr. - 6 months ago 7
SQL Question

how to use mutiple inner joins

How can I create a single sql comman to display the statements of accounts of one of the customer using inner join? help please, thanks.

enter image description here

Answer

I see that your custumers are identified by the telephone number, i don't think that is a good idea, since telephone number can change quite often in your custumer table, anyway this should be the query.

SELECT SA.* FROM STATAMENT_OF_ACCOUNT_TBL SA 
JOIN OFFICIAL_RECEIP_TBL R ON SA.STATEMENT_ACC_NO=R.STATEMENT_ACC_NO
JOIN CUSTUMER_TBL C ON C.CUS_TEL_NO=R.CUS_TEL_NO
WHERE C.CUS_TEL_NO='422-9418'

Ah, and there should not be null on the keys you are trying to join or it could result in nothing as results.

Comments