innerjoin
innerjoin inner joins between two tables.
- innerjoin(t1,t2) inner joins between two tables t1 and t2. It takes the unique matched column name as key variable
- innerjoin(t1,t2,'keys',n) n specifies the position of the column that will be taken as key variable
- innerjoin(t1,t2,'leftkeys',n,'rightkeys',m) key variables are the n-column of t1 and the m-column of t2
- innerjoin(t1,t2,'rightkeys',n,'leftkeys',m) key variables are the n-column of t2 and the m-column of t1
Examples
>> t1 = table({'a'}, 5)# Col1 Col2 a 5 >> t2 = table({'a';'b'}, [32; 43], 'VariableNames', {'Col1'; 'Col3'})# Col1 Col3 a 32 b 43 >> innerjoin(t1,t2)#% if there is just one common variable name, it is not needed to specify the key
Col1 Col2 Col3 a 5 32
>> t1 = table({'a';'b';'c'},[1;2;3])# Col1 Col2 a 1 b 2 c 3 >> t2 = table({'a';'c'},[pi;pi/2])# Col1 Col2 a 3.14159 c 1.5708 >> innerjoin(t1,t2,'keys',1)#% the key variable is the first column (Col1)
Col1 Col2 Col2_2 a 1 3.14159 c 3 1.5708
>> t1 = table([1;2;3], [4;3;2])# Col1 Col2 1 4 2 3 3 2 >> t2 = table([4;8;0], [3;2;6])# Col1 Col2 4 3 8 2 0 6 >> innerjoin(t1,t2,'leftKeys',1,'rightKeys',2)#key variables are the first column of t1 and the second of t2
Col1 Col2 Col1_2 2 3 8 3 2 4 >> innerjoin(t1,t2,'rightKeys',1,'leftKeys',2)# Col1 Col2 Col2_2 1 4 3