ExercisePaperDAOImpl
// 查询训练记忆试题
public List findTTMemory(int userid, int ttid, int ttgid) {
String sql = "select * from tbTTrainMemory where userid=? and ttid=? and ttgid=? order by dbms_random.value";
Object[] args = { userid, ttid, ttgid };
return basedao.getJdbcTemplate().queryForList(sql, args);
}
几个参数值为
userid =1 ttid =41 ttgid=21
select * from tbTTrainMemory where userid=1 and ttid=41 and ttgid=21 order by dbms_random.value
转变成mysql后
select * from tbTTrainMemory where userid=1 and ttid=41 and ttgid=21 order by rand();
// 查询训练记忆试题
public List findTTMemory(int userid, int ttid, int ttgid) {
String sql = "select * from tbTTrainMemory where userid=? and ttid=? and ttgid=? order by dbms_random.value";
Object[] args = { userid, ttid, ttgid };
return basedao.getJdbcTemplate().queryForList(sql, args);
}
几个参数值为
userid =1 ttid =41 ttgid=21
select * from tbTTrainMemory where userid=1 and ttid=41 and ttgid=21 order by dbms_random.value
转变成mysql后
select * from tbTTrainMemory where userid=1 and ttid=41 and ttgid=21 order by rand();
本文介绍了一种通过数据库查询特定用户、训练类型及组别下的训练记忆试题的方法,并展示了如何使用随机排序来获取这些试题的具体实现。以userid=1、ttid=41和ttgid=21为例,详细说明了在不同数据库环境下SQL语句的调整。

被折叠的 条评论
为什么被折叠?



