How to write a (MySQL) “LIMIT” in SQL Server?

前端 未结 2 839
傲寒
傲寒 2020-12-11 02:38

I have a problem when i try to change a query with LIMIT from MYSQL to SQL-Server.

Check that :

SELECT * 
FROM tableEating 
WHERE person = \'$identi         


        
2条回答
  •  执念已碎
    2020-12-11 02:56

    LIMIT does not work in T-SQL.

    You have to use TOP instead, like this:

    SELECT TOP(1) * FROM tableEating WHERE person='$identity';
    

    I hope that will work for you.

    As Aaron says, you also need an ORDER BY if you don't want to get an arbitrary row.

提交回复
热议问题