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

Sep 08, 2017 pm 01:48 PM
join using simplify

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!

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use JOIN in MySql How to use JOIN in MySql Jun 04, 2023 am 08:02 AM

How to use JOIN in MySql

What is the usage principle of MySQL Join? What is the usage principle of MySQL Join? May 26, 2023 am 10:07 AM

What is the usage principle of MySQL Join?

What are mysql's join query and multiple query methods? What are mysql's join query and multiple query methods? Jun 02, 2023 pm 04:29 PM

What are mysql's join query and multiple query methods?

How to use JOIN in MySQL How to use JOIN in MySQL Jun 03, 2023 am 09:30 AM

How to use JOIN in MySQL

Convert numpy to list: an effective strategy to simplify data processing process Convert numpy to list: an effective strategy to simplify data processing process Jan 19, 2024 am 10:47 AM

Convert numpy to list: an effective strategy to simplify data processing process

Use MySQL's JOIN function to join tables Use MySQL's JOIN function to join tables Jul 26, 2023 am 08:37 AM

Use MySQL's JOIN function to join tables

Null Coalesce operator in PHP7: How to simplify the conditional judgment of the code? Null Coalesce operator in PHP7: How to simplify the conditional judgment of the code? Oct 20, 2023 am 09:18 AM

Null Coalesce operator in PHP7: How to simplify the conditional judgment of the code?

How to optimize the join statement in MySQL How to optimize the join statement in MySQL Jun 03, 2023 am 09:31 AM

How to optimize the join statement in MySQL

See all articles