Cheng Plan--mysql Connection table

Source: Internet
Author: User

#inner join equivalent connection/INNER JOIN

Mysql> Select *  frominfo;+------+-------------+----------+|Name|Phone|Address|+------+-------------+----------+|Zhao| 13199999999 |Beijing||Qian| 1328888888  |Harbin||Sun| 13366666666 |Shanghai|+------+-------------+----------+3Rowsinch Set(0.00Sec
Mysql> Select *  fromscore;+----+------+-------+------------+|Id|Name|Score|Evaluation|+----+------+-------+------------+|  1 |Zhao| 98.00 | Ten         ||  2 |Qian| 90.30 | Ten         ||  3 |Sun| 70.00 | Ten         ||  4 |Li| 80.50 | Ten         |+----+------+-------+------------+4Rowsinch Set(0.00Sec

#inner join--Connect Some of the fields in two tables (filter columns) to form a table by the same name value (filter rows)

Mysql> SelectScore.id,score.name,info.phone fromScoreInner JoinInfo onScore.name=Info.name;+----+------+-------------+|Id|Name|Phone|+----+------+-------------+|  1 |Zhao| 13199999999 ||  2 |Qian| 1328888888  ||  3 |Sun| 13366666666 |+----+------+-------------+3Rowsinch Set(0.00Sec

#left join--reads all the values of the fields on the left table score, joins the fields in the two tables by the same name value to form the table (the table on the right does not have the corresponding record filled null)

Mysql> SelectScore.id,score.name,info.phone fromScore Left JoinInfo onScore.name=Info.name;+----+------+-------------+|Id|Name|Phone|+----+------+-------------+|  1 |Zhao| 13199999999 ||  2 |Qian| 1328888888  ||  3 |Sun| 13366666666 ||  4 |Li| NULL        |+----+------+-------------+4Rowsinch Set(0.00Sec

#类似的有right Join

Mysql> SelectScore.id,score.name,info.phone fromScore Right JoinInfo onScore.name=Info.name;+------+------+-------------+|Id|Name|Phone|+------+------+-------------+|    1 |Zhao| 13199999999 ||    2 |Qian| 1328888888  ||    3 |Sun| 13366666666 |+------+------+-------------+3Rowsinch Set(0.00Sec

Cheng Plan--mysql Connection table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.