数据库更新??
Connection conn=DB.getConn();
String s="select max(id) from article group by rootid";
ResultSet rs=DB.executeQuery(conn,stmt,s);
rs.next();
int rootid=rs.getInt(1)+1;
String sql="insert into article value(null,0,?,?,?,now(),0)";
PreparedStatement pstmt=DB.preparedStatement(conn,sql);
pstmt.setInt(1,rootid);
pstmt.setString(2,title);
pstmt.setString(3,cont);
pstmt.executeUpdate();
DB.close(rs);
DB.close(stmt);
DB.close(pstmt);
DB.close(conn);
完成这次的插入操作后 rootid得到的值一直不变。。。怎么回事?
rootid=11
rootid=11
rootid=11
rootid=11
------解决方案--------------------
select max(id) from article group by rootid
------解决方案--------------------
group by 是分组 order by 排序 楼主细心