bilbaoWon bilbaoWon - 2 months ago 7
MySQL Question

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

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

Check that :

FROM tableEating
WHERE person = '$identity'

I tried to change it with some queries but nothing work.


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.