我在 Python3 中使用 SQLite3 查询得到了意想不到的结果。
if first_waypoint_number < last_waypoint_number:
result = list(c.execute("SELECT WPNumber, WPID, ROUTE FROM rte WHERE ROUTE = ? AND WPNumber BETWEEN ? AND ?", (route, first_waypoint_number, last_waypoint_number)))
print(result)
else:
result = list(c.execute("SELECT WPNumber, WPID, ROUTE FROM rte WHERE ROUTE = ? AND WPNumber BETWEEN ? AND ? ORDER BY WPNumber DESC", (route, first_waypoint_number, last_waypoint_number)))
print(result)
第一个查询按预期工作,并产生以下结果:
[('A123', 25, 'WAYPOINTX'), ('A123', 26, 'WAYPONTY'), ('A123', 27, 'WAYPOINTZ')]
然而,第二个查询产生一个空列表[]
,而它应该以相反的顺序返回相同的列表。
我已经在 SQLite3 中测试了这两个查询,没有问题。
我在这里错过了什么吗?