请一句sql查询

无恶不作的黑猫警长 2020-05-15 10:48:25
用一句sql,查出学生名字及所有科目名和科目成绩,没有相应成绩的,用'-'显示

...全文
117 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
SELECT student.name, IFNULL(score.subject, '-') as subject, IFNULL(score.score, '-') as score FROM student LEFT JOIN score ON score.uid = student.id;
带我飞的云 2020-05-16
  • 打赏
  • 举报
回复
SELECT t.name, s.`subject`, IFNULL(s.score,'-')
FROM student AS t
INNER JOIN score AS s ON s.uid = t.id

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧