Home > Database > Mysql Tutorial > How to use JOIN USING in sql to simplify JOIN ON examples

How to use JOIN USING in sql to simplify JOIN ON examples

黄舟
Release: 2017-09-08 13:48:21
Original
1955 people have browsed it

In the join SQL statement in Mysql, the syntax format of the ON clause is: table1.column_name = table2.column_name.

When the schema design adopts the same naming style for the columns of the joined table, the USING syntax can be used to simplify the ON syntax, with the format: USING(column_name).

For example:


[sql]
SELECT f.color, c.is_primary, c.is_dark, c.is_rainbow  
FROM flags f    www.2cto.com  
INNER JOIN color c ON f.color = c.color  
WHERE f.country = 'China';
Copy after login

is equivalent to


[sql]
SELECT f.color, c.is_primary, c.is_dark, c.is_rainbow  
FROM flags f  
INNER JOIN color c USING(color)  
WHERE f.country = 'China';
Copy after login

The above is the detailed content of How to use JOIN USING in sql to simplify JOIN ON examples. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template