Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have 4 tables, each with a common field QuestionnaireId.

I am wondering if there is any difference in output or performance difference between using USING on the field in each join or by specifying the ON QuestionnaireId relations between each join.

Case A:

Select * FROM 
    StudyQuestionnaire
    INNER JOIN QuestionnaireScore USING (QuestionnaireScoreId)
    INNER JOIN Questionnaire USING (QuestionnaireScoreId)
    INNER JOIN QuestionnaireScoreTags USING (QuestionnaireScoreId);

Case B:

Select * FROM 
    StudyQuestionnaire SQ
    INNER JOIN QuestionnaireScore QS ON SQ.QuestionnaireScoreId = QS.QuestionnaireScore
    INNER JOIN Questionnaire Q ON QS.QuestionnaireScoreId = Q.QuestionnaireScoreId
    INNER JOIN QuestionnaireScoreTags QST ON Q.QuestionnaireScoreId = QST.QuestionnaireScoreId;
share|improve this question
    
USING is just shorthand notation. en.wikipedia.org/wiki/Join_(SQL) –  eroomydna Feb 18 at 17:26
    
There is a difference in output, if you are using SELECT *. The ON query will show four QuestionnaireScoreId columns, the USING query will show one. –  ypercube Feb 18 at 17:45
    
other than number of outputted fields though, the overall joining is the exact same right? Also forgot that they are not all inner joins, some may be left joins. –  Raymond Feb 18 at 17:56
    
Performance wise it's the same –  Sam D Feb 18 at 18:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.