最后挂单我有Customers
创造了一些Order
小号存储在订单postgres
db.Some可能有'pending'
status.I希望用户能够在他的最后挂单工作。检索客户
顺序表
id | order_num | order_date |customer_id | status
-----+-----------+------------+------------+---------
80 | 1234 | 02-01-2000 | 20 | pending
----------------------------------------------------
81 | 2345 | 02-01-2000 |20 | confirmed
-----------------------------------------------------
82 | 3456 | 02-01-2000 |20 | pending
--------------------------------------------------
83 | 3498 | 02-001-2000| 20 | confirmed
----------------------------------------------------
这有什么错用
select * from orders where customer_id =20 and status='pending' order by id DESC limit 1
多个记录的order_date的可能same.The订单号可能并不总是按升序排列。在这方面是否通过id命令安全?
如何根据'order_num'排序? –