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