有一张表t_card_question
字段 card_id (答题卡UID)
question_id(题目UID)
card_question_index(题目在一张答题卡上对应的编号)(最大值不固定)描述:表中有多张答题卡(多个card_id)要求查询出:表中每个card_id对应的最大card_question_index的question_id
字段 card_id (答题卡UID)
question_id(题目UID)
card_question_index(题目在一张答题卡上对应的编号)(最大值不固定)描述:表中有多张答题卡(多个card_id)要求查询出:表中每个card_id对应的最大card_question_index的question_id
解决方案 »
- MYSQL主键自增是否可以从0开始
- 如何用MYSQL把数据放到oracle里啊
- Mysql的like查询 特殊字符
- 请教一个union,sum 和group by一起用的语句
- 求mysql查询语句
- Linux平台上我的Mysql启动不了了
- 这台 MySQL 服务器可以通过 1000 人的并发测试吗?
- mysql多表查询之后返回的结果:2个表的某个字段同名,有什么好的方法区分并取出
- 怎么去除数据库字段重复的值
- 往数据库text类型字段 加数据出现问题com.mysql.jdbc.exceptions.MySQLSyntaxErrorException:
- 关于远程MYSQL服务器的问题
- mysql c接口开发的小程序 占用内存越来越大?
from t_card_question a
where not exists (select from t_card_question where card_id=a.card_id and card_question_index>a.card_question_index)
from t_card_question a
where card_question_index=(select max(card_question_index) from t_card_question where card_id=a.card_id)select a.card_id,a.question_id
from t_card_question a inner join (select card_id,max(card_question_index) as card_question_index from t_card_question group by card_id) b
on a.card_id=b.card_id and a.card_question_index=b.card_question_index