String sql = "select top 30 * from msgInfo where ID in(select top 30 ID from msgInfo where chatRoom=? order by chatTime DESC) order by chatTime" ;
PreparedStatement ps = conn.preparedStatement(sql) ;
ps.setString(1,request.getSession().getAttribute("CHAT_ROOM").toString()) ;
错误:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '30 * from msgInfo where ID in(select top 30 ID from msgInfo where chatRoom='新' at line 1
中文是新闻
(select top 30 ID from msgInfo where chatRoom=? order by chatTime DESC)这样是要查前30条的ID where chatRoom=? 这个位
“=”匹配只会有一条的输出吧 如果你的chatRoom是字符串的类型 应该不是中文的问题 你把“=”改成like“试试 我瞎猜的 不一定对
应该是select子查询里面不能排序吧,子查询里不能嵌套排序吧