当前位置: 技术问答>java相关
数据库查询取得最大的一个值
来源: 互联网 发布时间:2015-06-17
本文导语: sql="select MAX(useid) from register"; ResultSet RS1=stmt.executeQuery(sql); while(RS1.next()) { id=RS1.getInt("useid"); } 提示:javax.servlet.ServletException: Column not found 我是想取得useid列的最大值,其数据为int型。Column not found ?? | ...
sql="select MAX(useid) from register";
ResultSet RS1=stmt.executeQuery(sql);
while(RS1.next())
{
id=RS1.getInt("useid");
}
提示:javax.servlet.ServletException: Column not found
我是想取得useid列的最大值,其数据为int型。Column not found ??
ResultSet RS1=stmt.executeQuery(sql);
while(RS1.next())
{
id=RS1.getInt("useid");
}
提示:javax.servlet.ServletException: Column not found
我是想取得useid列的最大值,其数据为int型。Column not found ??
|
你这样试试,祝你好运!
sql="select MAX(useid) USEID from register";
ResultSet RS1=stmt.executeQuery(sql);
while(RS1.next())
{
id=RS1.getInt("USEID");
}
sql="select MAX(useid) USEID from register";
ResultSet RS1=stmt.executeQuery(sql);
while(RS1.next())
{
id=RS1.getInt("USEID");
}
|
sql语句改成"select MAX(useid) as useid from register";
因为数据集中的字段名为MAX(useid),所以找不到
因为数据集中的字段名为MAX(useid),所以找不到
|
sql="select MAX(useid) from register";
: Column not found
是不是你的列名打错了,是useid吗?不会是userid吧
: Column not found
是不是你的列名打错了,是useid吗?不会是userid吧
|
sql="select MAX(useid) as count from register";
ResultSet RS1=stmt.executeQuery(sql);
while(RS1.next())
{
id=RS1.getInt("count");
}
ResultSet RS1=stmt.executeQuery(sql);
while(RS1.next())
{
id=RS1.getInt("count");
}