MySQL Basic operation

Source: Internet
Author: User
Tags ming

Database Connection diagram

Student table and class table take left outer connection

Select S.stuid,s.name,c.class from students as s left join classes as C on s.classid=c.classid;+-------+---------------+-- --------------+| Stuid | name |     Class |+-------+---------------+----------------+| 1 | Shi Zhongyu |     Emei Pai | | 2 | Shi Potian |     Shaolin Pai | | 3 | Xie Yanke |     Emei Pai | | 4 | Ding Dian |     Wudang Pai | | 5 | Yu Yutong |     Qingcheng Pai | | 6 | Shi Qing |     Riyue Shenjiao | | 7 | Xi Ren |     Qingcheng Pai | | 8 | Lin Daiyu |     Ming Jiao | | 9 | Ren Yingying |    Lianshan Pai | | 10 | Yue Lingshan |    Qingcheng Pai | | 11 | Yuan Chengzhi |    Lianshan Pai | | 12 | Wen qingqing |    Shaolin Pai | | 13 | Tian Boguang |    Emei Pai | | 14 | Lu Wushuang |    Qingcheng Pai | | 15 | Duan Yu |    Wudang Pai | | 16 | Xu Zhu |    Shaolin Pai | | 17 | Lin Chong |    Wudang Pai | | 18 | Hua Rong |    Ming Jiao | | 19 |  Xue Baochai |    Lianshan Pai | | 20 | Diao Chan |    Ming Jiao | | 21 | Huang yueying |    Lianshan Pai | | 22 | Xiao Qiao |    Shaolin Pai | | 23 | Ma Chao |    Wudang Pai |# | 24 | Xu Xian |    NULL |# | 25 | Sun Dasheng | NULL |+-------+---------------+----------------+ Student table and class table take left outer join, and subtract student table from curriculum intersection section select S.stuid,s.name,c.class from S Tudents as S left join classes as C in S.classid=c.classid where C.classid is null;+-------+-------------+-------+| Stuid | name |    Class |+-------+-------------+-------+| 24 | Xu Xian |    NULL | | 25 | Sun Dasheng | NULL |+-------+-------------+-------+ calculates the average of girls ' scores select AVG (age) from students group by gender have gender= ' F ';

MySQL basic operations

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.