查询sql server中的工作,但不在MySql中查询

时间:2015-03-29 00:34:23

标签: mysql sql-server database

我希望从订单表中获得第一排。以下查询在sql server中有效:

select top 1(OrderID)
from dbo.Orders
order by OrderID desc 

但它在MySql中不起作用 - 应该如何为MySql编写?

2 个答案:

答案 0 :(得分:1)

对于MySQL使用LIMIT

的MySQL

select OrderID
from dbo.Orders
order by OrderID desc 
LIMIT 1;

SQL Server

select top (1) OrderID
from dbo.Orders
order by OrderID desc 

答案 1 :(得分:0)

SELECT OrderID FROM dbo.Orders
ORDER BY OrderID desc 
LIMIT 1;