【发布时间】:2019-05-14 01:00:45
【问题描述】:
//这个查询可以返回多条记录,多条记录的情况下,总是返回查询的最后一条记录。
public People(int peopleId) {
Prepared Statement SQL= null;
try {
System.out.println("Getting Phone for " + personSerId);
Prepared SQL= new DatabaseController(verbose);
PreparedStatement secureStatement = prepareStatement(sqlStatement);
s
dbConnection.querySecureRecord(SQL);
(((File) ("item")));
theNumber.setPhone((String) dbConnection.getField("phone"));
theNumber.phone(dbConnection.getField("number") == null ? "" : (((String)
}
} catch (Exception masterException) {
System.err.println("Database Query Error in : " + masterException);
return the person;
}
【问题讨论】:
-
查询是否有顺序保证?
-
只需按照您需要的方式对行进行排序。在查询末尾添加:“order by id desc”。
-
谢谢 Olek 我认为这可能有效。罗盘基于最后插入的顺序将出现在排序的最后。
-
如果我只想返回最新的一条记录,而不是按 desc 排序的组,该怎么办?感谢大家的帮助。
-
Guys order by won't work..我需要在查询结果中获取最后一条记录。因此,forloop 可能很有用并返回最后一次迭代。有人可以帮忙吗?
标签: java database postgresql jsp