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
LIMIT
does not work and TOP(1)
may also not work in nested statements.
So the right approach is to use OFFSET... FETCH NEXT
:
SELECT * FROM TableName
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
That basically tells TSQL to take one row (NEXT 1 ROWS ONLY
) starting from the first one (OFFSET 0
).
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.