当前位置: 首页 > news >正文

MySQL行列转换

创建一个sc表并插入数据

方法一:

select distinct uid,
(select score from sc where s.uid=uid and course='语文')语文,
(select score from sc where s.uid=uid and course='数学')数学,
(select score from sc where s.uid=uid and course='英语')英语
from sc s;

方法二:

select * from sc where course='语文';
select * from sc where course='数学';
select * from sc where course='英语';

把这三条数据当做三个表

select y.uid,y.score 语文,s.score 数学,e.score 英语
from (SELECT * FROM `sc` where course='语文') y
left join (SELECT * FROM `sc` where course='数学') s
on y.uid=s.uid
left join (SELECT * FROM `sc` where course='英语') e
on y.uid=e.uid;

相关文章:

  • 外贸公司都是在什么网站做推广外贸接单网站
  • 哈尔滨制作网站的公司百度云app下载安装
  • 申请个人手机网站空间长春网站优化平台
  • wordpress界面只有文字吉安seo招聘
  • 公司网站建设论文wordpress网站建设
  • 做脚垫版型的网站建网站需要什么
  • 数据泄露与防范
  • C++进阶——C++11_右值引用和移动语义_可变参数模板_类的新功能
  • window部署虚拟机VirtualBox来部署flink
  • 网络机顶盒怎么连接WiFi-机顶盒连接wifi攻略,轻松畅享网络视听
  • 我为女儿开发了一个游戏网站
  • gerrit配置及使用git-lfs
  • c++11新内容补充
  • c++类和对象——this指针
  • Vue Router(2)
  • Spring AI开发MCP Server和MCP Client
  • 从一批视频里面抽取固定的第n帧图片(包含并行实现)
  • lanqiaoOJ 551 灌溉
  • 回溯算法+对称剪枝——从八皇后问题到数独问题(二)
  • 基于autokeras的简单天气预报例子和运行输出
  • Maven 基础知识
  • HarmonyOS-ArkUI 装饰器V2 @ObservedV2与@Trace装饰器
  • 3ds Max 2016的版本怎么处理 按键输入被主程序截断 C#winform窗体接受不到英文输入
  • linux入门六:Linux Shell 编程
  • c++的函数重载
  • 机器学习 | 强化学习方法分类汇总 | 概念向