Home > Database > Mysql Tutorial > What is generally used for mysql multi-table queries?

What is generally used for mysql multi-table queries?

青灯夜游
Release: 2020-10-20 10:25:56
Original
2029 people have browsed it

Mysql multi-table queries generally use cross joins, inner joins and outer joins. Cross-join returns the Cartesian product of the connected tables; inner join combines records in two tables and returns records with matching associated fields, that is, returns the intersection of the two tables; outer join first divides the connected tables into base tables and Reference table, and then return records that meet and do not meet the conditions based on the base table.

What is generally used for mysql multi-table queries?

(Recommended tutorial: mysql video tutorial)

In a relational database, the relationship between tables is There is a relationship, so in practical applications, multi-table queries are often used. Multi-table query is to query two or more tables at the same time.

In MySQL, multi-table queries mainly include cross joins, inner joins and outer joins.

Cross join

Cross join (CROSS JOIN) is generally used to return the Cartesian product of the join table.

The syntax format of cross-connection is as follows:

SELECT <字段名> FROM <表1> CROSS JOIN <表2> [WHERE子句]
Copy after login

or

SELECT <字段名> FROM <表1>, <表2> [WHERE子句]
Copy after login

The syntax description is as follows: