当前位置:Gxlcms > 数据库问题 > MySQL连表查询

MySQL连表查询

时间:2021-07-01 10:21:17 帮助过:8人阅读

  以学生表、成绩表和考勤表为例:

  1、创建数据库:

    create database 数据库;

  连表学生总成绩降序排列:

    select score.g_id,student.name,score.total from student,score where score.s_id=student.s_id order by score.total desc;

  从成绩表中和学生表中找总成绩最高的学生:

  select 成绩表.g_id,学生表.name,成绩表.total from 学生表 inner join 成绩表 on 学生表.s_id=成绩表.s_id group by 学生表.s_id order by max(成绩表.total) desc limit 1;
  select score.g_id,student.name,score.total from student,score where score.s_id=student.s_id order by score.total desc limit 1;

 

 

 

 

MySQL连表查询

标签:操作   create   desc   from   sql   order by   span   col   创建数据库   

人气教程排行