MySQL aliases
SELECT concat_ws ('as ' full name ' #CONCAT_WS函数用于字符串的拼接FROM Employees;
Mysql-inner JOIN operation
Description: Matches rows in one table with rows in other tables, and allows querying of row records containing columns from two tables.
INNER JOIN语
Before a sentence, you must specify the following conditions:
First, specify the primary table in the FROM statement.
Second, the main table in the table to be connected should appear in the INNER JOIN语
sentence. Theoretically, you can connect multiple other tables. However, to get better performance, you should limit the number of tables you want to connect (preferably not more than three tables).
Third, the connection condition or connection predicate. The join condition appears INNER JOIN
after the keyword of the statement ON
. A join condition is a rule that matches rows in a primary table with rows in other tables.
Suppose you use a INNER JOIN clause to connect two tables: T1 and T2
SELECT column_listfrom t1inner JOIN T2 on Join_condition;
For t1
each row in the table, the INNER JOIN
statement compares it to t2
each row of the table to check whether they satisfy the join condition. When the join condition is met, a new row is returned that consists of the INNER JOIN
t1
t2
columns in the table.
Note that the t1
t2
rows in the table and the tables must match according to the join criteria. If no match is found, the query returns an empty result set. 2
This logic is also applied when more than one table is connected.
Mysql-left JOIN operation
Features: Querying data from two or more database tables.
Suppose you want to query data from two tables T1 and T2. SELECT t1.c1, T1.c2, T2.C1, t2.c2from T1 left JOIN = t2.c1;
When you use a statement to join a table to a LEFT JOIN
t1
t2
table, the t1
row t1.c1 = t2.c1
t2
is included in the result set if the rows from the left table match the right table based on the join condition ().
If the rows in the left table do not match the rows in the right table, the rows in the left table are also selected and combined with the false rows in the right table. The false row SELECT
contains values for all corresponding columns in the clause NULL
.
Mysql-cross JOIN operation
功能介绍:CROSS JOIN语
A sentence returns the Cartesian Descartes product of a row from a connected table.
Connect two tables: syntax for CROSS join clauses for T1 and T2: SELECT *from T1 cross JOIN T2;
List all the two sheets.
Result table: Column = The number of columns in the original table is added, row = row number of the original table multiplied
mysql-Table Connection