Database table connection method

There are three connection modes: internal connection, external connection, and cross connection.

1. Internal connection

Use the comparison operator to compare the connection of the values ​​of the columns to be connected, and the rows that do not match will not be displayed. The sql keyword JOIN or INNER JOIN is usually written as JOIN.

2. External connection

① External connection is divided into: left external connection, right external connection, and full external connection.

② Corresponding sql keyword: LEFT/RIGHT/FULL OUTER JOIN, usually omitted OUTER keyword, written as LEFT/RIGHT/FULL JOIN.

③ In the left and right outer joins, a table is used as the base table, and all rows and columns of the base table are displayed. If the outer table does not match the condition, all outer table column values ​​are NULL.

For a full outer join, all rows and columns of the table will be displayed, and the values ​​that do not match the conditions are all NULL.

3. Cross Connect

The cross join without the where condition will produce the Cartesian product involved in the join table, that is, the result set of the number of rows in TableA * the number of rows in TableB. If with where, the number of matching rows is returned or displayed. (You can only use where after cross join, not on)

Guess you like

Origin blog.csdn.net/aqiuisme/article/details/113822433