Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql resultset.next()以获取更少的记录_Mysql_Jsp - Fatal编程技术网

Mysql resultset.next()以获取更少的记录

Mysql resultset.next()以获取更少的记录,mysql,jsp,Mysql,Jsp,我有一个时间段,比如10:00到12:00,我有一个表table12,只有3个用户(3条记录) for(int i=0;i<2;i++){ ResultSet rsta=st.executeQuery("Select * from details where user_type='user'"); while(rsta.next()){ <table> <td><input type="text" name="name<%=count%>" id

我有一个时间段,比如10:00到12:00,我有一个表
table12
,只有3个用户(3条记录)

for(int i=0;i<2;i++){
ResultSet rsta=st.executeQuery("Select * from details where user_type='user'");
while(rsta.next()){
<table>
<td><input type="text"  name="name<%=count%>" id="name<%=count%>" value="<%=rsta.getString("user")%>" ></input></td>
 </table>
 }
 }
我想要的结果就是这么多

10:00-user1;
10:30-user2;
11:00-user3;
11:30-user1;
我需要在11:30从表12中获取第一条记录。可能吗?

while(rsta.next())
已经在结果集上循环。您不需要为
循环添加
,而
循环:

ResultSet rsta = st.executeQuery("SELECT * FROM details WHERE user_type='user' LIMIT 4")

while(rsta.next()){
    rsta.getString("user")
}

select*from table 12 limit 4
oh yes..忘了这一点。我还有一个where子句。我把limit放在where子句之后?应该是beofre吗?
select*from table 12where something=有趣的limit 4
No没有起作用。我想这是因为for循环。我得到了同样的错误结果,但我只有3个记录在那里。user1、user2、user3.So limit无论如何只会给出3个结果..所以我需要再次循环相同的查询。limit会给您找到的记录数,最多是您限制的数量(在本例中为4)。如果在限制设置为4的情况下返回3个结果,则表示数据库中只有3个与搜索匹配的结果。你想生成比你实际拥有的更多的记录吗?是的,我那里只有3条记录,user1,user2,user3。这就是为什么我试图再次迭代该查询,以便它可以再次在相同的用户上执行相同的查询。你需要重新表述你的问题,以准确地解释你拥有什么,以及你想做什么。我很难理解你想要实现什么。
ResultSet rsta = st.executeQuery("SELECT * FROM details WHERE user_type='user' LIMIT 4")

while(rsta.next()){
    rsta.getString("user")
}