m0_62452255 2022-09-29 09:49 采纳率: 85.7%
浏览 67
已结题

关于#sql#的问题,请各位专家解答!

img

向上图这样的情况 应该用哪种方法进行联表查询

第一个问题我写出来了,不知道对不对


select class 班级,countcase when sex='男' then 1 endas 男,
countcase when sex='女' then 1 endasfrom table1 group by class
  • 写回答

2条回答 默认 最新

  • Java大魔王 2022-09-29 10:24
    关注
    1.
    select `class`,count(id), sex from table1 group by class,sex
    
    2.
    select a.`class`, a.name, b.Yw,b.Sx from table1 a lfet join table2 b on a.id = b.id
    
    3.
    select `class`,count(*) from table1 a left join table2 b on a.id = b.id and b.Yw > 90 group by class
    
    4.
    update table2 set Yw = 95 where id = 'E9C74592A90C21D8E0533903190A764A'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 9月29日
  • 已采纳回答 9月29日
  • 修改了问题 9月29日
  • 修改了问题 9月29日
  • 展开全部