我希望从订单表中获得第一排。以下查询在sql server中有效:
select top 1(OrderID)
from dbo.Orders
order by OrderID desc
但它在MySql中不起作用 - 应该如何为MySql编写?
答案 0 :(得分:1)
对于MySQL使用LIMIT
select OrderID
from dbo.Orders
order by OrderID desc
LIMIT 1;
select top (1) OrderID
from dbo.Orders
order by OrderID desc
答案 1 :(得分:0)
SELECT OrderID FROM dbo.Orders
ORDER BY OrderID desc
LIMIT 1;