Create a table needed
- Create t1, t2 Table Create Table T1 ( key1 VARCHAR (20 is), V1 int (. 4) ); ## ,, import data stored in the data may not have Chinese characters following the path load data local infile 'E: / data /t1.csv ' INTO T1 Table Fields terminated by', ' the ignore Lines. 1; SELECT * from T1; Create Table T2 ( key2 VARCHAR (20 is), V2 int (. 4) ); Load Data local INFILE' E: / Data / t2.csv ' INTO Table T2 Fields terminated by', ' the ignore Lines. 1;
- connect the left and right connections and internal connections
## left connecting SELECT * from the Join left T1 = T2 ON t1.key1 t2.key2; ## right connecting select * from t1 right join t2 on t1.key = t2.key2; connections within ## SELECT * from the Join Inner T1 t2.key2 t1.key1 = ON T2; ## combined query SELECT * from T1 union ## to eliminate duplicate fields with the union not eliminate duplicate fields All union SELECT * from T2; - Cartesian product: select field 1 [, ... ] from table 1, table 2 [, ...]; SELECT * from T1, T2; - elimination Cartesian product: select field 1 [, ...] from table 1, table 2 [, ...] where table 1.key = table 2.key; SELECT * T1, T2 from ; WHERE t1.key1 = t2.key2 SELECT * from the Join cross T1 = T2 ON t1.key1 t2.key2; cross-connect ## ## Note :: Cartesian product after elimination and the results of the same cross-connect ### in a fully connected mysql no fully connected, but can be combined and right connections to the weight obtained by the left; SELECT * from the Join left T1 = T2 ON t1.key1 t2.key2 Union select * from t1 right join t2 on t1.key = t2.key2;