多合一查詢

2021-05-24 14:01:32 字數 1430 閱讀 1390

create table student(num varchar(20),name varchar(20),subject varchar(10),score float)

insert  student select '001','姓名1','英語',78.00

insert  student select '001','姓名1','數學',88.00

insert  student select '001','姓名1','政治',98.00

insert  student select '002','姓名2','英語',58.00

insert  student select '002','姓名2','數學',48.00

insert  student select '003','姓名3','英語',38.00

insert  student select '003','姓名3','數學',28.00

drop table student

create table student(num varchar(20),name varchar(20),subject varchar(10),score float)

insert  student select '001','姓名1','英語',78.00

insert  student select '001','姓名1','數學',88.00

insert  student select '001','姓名1','政治',98.00

insert  student select '002','姓名2','英語',58.00

insert  student select '002','姓名2','數學',48.00

insert  student select '002','姓名2','政治',96.00

insert  student select '003','姓名3','英語',38.00

insert  student select '003','姓名3','數學',28.00

insert  student select '003','姓名3','政治',97.00

select distinct a1.num,a1.name,c2.subject,c2.score, c1.subject,c1.score, c3.subject,c3.score

from student a1 ,

(select * from student b2 where b2.subject='數學') c1,

(select * from student b1 where b1.subject='英語' ) c2,

(select * from student b3 where b3.subject='政治' ) c3

where a1.num=c1.num and a1.num=c2.num and a1.num=c3.num

mybais 多對一查詢

準備階段 多個學生對應乙個老師 1.建表 2.編寫實體類 package com.lv.pojo import lombok.data data public class student package com.lv.pojo import lombok.data data public class...

人證合一查驗系統

細心的你一定會發現,雖然酒店實名登記已經進行了多年,但是在登記的過程中還存在著諸多弊端,比如 證件單一,一般都是採用身份證登記的形式 無法將證件和本人做對比,出現了拿別人身份證也能住宿的情況 無法保留住宿人實時影象,供今後呼叫,等等。上述確實給酒店的客戶登記造成了不小的麻煩,同時使客戶管理更加的困難...

MyBatis多對一查詢的使用

一.丟擲問題 什麼是多對一 如何在查詢訂單的時候帶出使用者表中的使用者名稱?二.解決方式 1.單查詢屬性對映 public class order select id getbyid resulttype order select o.u.account useraccount from mall ...