Home >Database >Mysql Tutorial >How to use on in mysql
The ON clause is used to specify the conditions for comparing and merging rows of two tables in JOIN operations, including inner joins, left outer joins, right outer joins and full outer joins. The ON condition uses only equality comparisons, you can use multiple conditions to specify more complex join rules, and can be used with other JOIN types.
Usage of ON in MySQL
Overview of ON clause
## The #ON clause is used to specify conditions for comparing and merging rows from two tables in a JOIN operation.Syntax
<code>ON 表1.列名 = 表2.列名</code>
Usage
Example
Inner join:
<code>SELECT * FROM 表1 INNER JOIN 表2 ON 表1.id = 表2.id;</code>
Left outer join:
<code>SELECT * FROM 表1 LEFT OUTER JOIN 表2 ON 表1.id = 表2.id;</code>
Right outer join:
<code>SELECT * FROM 表1 RIGHT OUTER JOIN 表2 ON 表1.id = 表2.id;</code>
Full outer join:
<code>SELECT * FROM 表1 FULL OUTER JOIN 表2 ON 表1.id = 表2.id;</code>
Notes
The above is the detailed content of How to use on in mysql. For more information, please follow other related articles on the PHP Chinese website!