studentNo pass
A 語文
A 數學
A 英語
A 地理
B 語文
B 數學
B 英語因為學生A過了4門課,所以給他的科目分別加上1234的序號
B學生過了3門,所以給他的科目加上123的序號,
效果如下:NO studentNo pass
1 A 語文
2 A 數學
3 A 英語
4 A 地理
1 B 語文
2 B 數學
3 B 英語請問在Mysql的查詢中如何得到這樣的結果?多謝。
A 語文
A 數學
A 英語
A 地理
B 語文
B 數學
B 英語因為學生A過了4門課,所以給他的科目分別加上1234的序號
B學生過了3門,所以給他的科目加上123的序號,
效果如下:NO studentNo pass
1 A 語文
2 A 數學
3 A 英語
4 A 地理
1 B 語文
2 B 數學
3 B 英語請問在Mysql的查詢中如何得到這樣的結果?多謝。
解决方案 »
- MySql 学习资料
- 如何将GBK的数据转成UTF8的?
- mysql可不可以備份表結構而不備份裡面的數據
- mysql数据库。 这样的操作sql该怎么写?
- 在个问题在国内上怎么没有人问呀,我来问问大家看看mysql和java在unix下面连接出错的问题
- MySQL的最新版本是多少 ,有什么改进,大家用了之后有什么感受,怎么解决事务处理的?
- 误操作数据恢复
- mysql select 问题
- 问个简单的索引问题 在线等
- 关于mybaits使用mysql动态查询
- MySQL Server and Client与Command-Line Utilities
- mysql 6.0 官方网站上怎么找不到呢?哪位能提供连接?
update tb set no =1 where pass='語文'
update tb set no =2 where pass='數學'
update tb set no =3 where pass='英語'
update tb set no =4 where pass='地理'
select case
when pass='語文' then 1
when pass='數學' then 2
when pass='英語' then 3
when pass='地理' then 4
end as no
studentNo,pass from tb
update tb set no =1 where pass='語文'
update tb set no =2 where pass='數學'
update tb set no =3 where pass='英語'
update tb set no =4 where pass='地理'select count(tb1.*)as no,tb1.studentNo,tb1.pass from tb as tb1,tb as tb2 where
tb1.no<=tb2.no and tb2.studentNo=tb1.studentNo
select stu.* from (select @i:=@i+1 as i,studentNo from student) stu,
(select count(*) c, studentNo from student group by studentNo ) b where stu.i<=b.c and stu.studentNo=b.studentNo;
select a.* , d.i
from student a,(select stu.* from (select @i:=@i+1 as i,studentNo,pass from student) stu,
(select count(*) c, studentNo from student group by studentNo ) b where stu.studentNo=b.studentNo) d
where a.studentNo=d.studentNo and a.pass =d.pass;
from tbl1 t;