gpt4 book ai didi

jquery - Mysql ORDER BY length(col), col 不工作

转载 作者:行者123 更新时间:2023-11-29 06:36:56 26 4
gpt4 key购买 nike

     Mysql employee table 

Mysql database table

注意:这里的emp_id是varchar

  String query="select * from employee ORDER BY length(emp_id),emp_id";

if i run only the above query it works fine......
Query ouput :

enter image description here

当我运行下面的 jsp 代码时,这个查询不起作用

<html><head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<link href="jquery.dataTables.css" rel="stylesheet" type="text/css"/>
<script src="jquery.dataTables.js"></script>
</head>
<body>
<div class="container">
<table id="example" class="display" width="100%" border="1">
<thead><tr>
<th>EMPLOYEE_ ID</th>
<th>NAME</th>
<th>DEPARTMENT</th>
<th>DESIGNATION</th>
</tr></thead>
<tbody>
<%
try
{
String query="select * from employee ORDER BY length(emp_id),emp_id";
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{
%>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
</tr>
<% } %>
</tbody></table>
<%
rs.close(); stmt.close();con.close();
}
catch(Exception e)
{ e.printStackTrace(); }
%>
</div>
<script>
$(document).ready( function () {
var table = $('#example').DataTable();
} );
</script></body></html>

jsp 的输出:

enter image description here注意:在我的表中 emp_id 是 varchar................................................ ..................................................... .....................................请帮助我....

最佳答案

可能是您的 jquery 采用了默认的排序样式...

关于jquery - Mysql ORDER BY length(col), col 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23968224/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com