필터 지우기
필터 지우기

What is the difference between inner join and join?

조회 수: 40 (최근 30일)
JFz
JFz 2018년 1월 12일
댓글: JFz 2018년 6월 18일
I have two tables, A and B. They are almost identical but in different sorted by rows.
I would like to tie them up by rows. Should I use innerjoin or join?
What is the difference between inner join and join? Thanks for any help.

채택된 답변

Jan
Jan 2018년 1월 12일
편집: Jan 2018년 1월 12일
For a join both tables requires the same variables. For an innerjoin the overlapping variables are chosen.
A look into the documentation is useful:
help join
help innerjoin
You can create an innerjoin of:
a = table({'a' 'b' 'c' 'e' 'h'}', [1 2 3 11 17]', 'VariableNames',{'Key1' 'Var1'})
b = table({'a' 'b' 'd' 'e'}', [4 5 6 7]', 'VariableNames',{'Key1' 'Var2'})
The result contains the overlapping keys 'a', 'b', 'e' only. You cannot join them due to the not matching 'c' and 'h'. But you can join:
a = table({'a' 'b' 'c' 'e' 'h'}', [1 2 3 11 17]', 'VariableNames', {'Key1' 'Var1'})
b = table({'a' 'b' 'h' 'e' 'c'}', [4 5 6 7 8]', 'VariableNames', {'Key1' 'Var2'})
Here the join and innerjoin give the same results, so it does not matter, which one you run.
Note:
  • join: both tables need the same keys
  • innerjoin: The result contains the overlapping keys only
  • outerjoin: The result contains all keys of both tables and fills missing values with dummies.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by