This question already has answers here:
How to write a (MySQL) "LIMIT" in SQL Server? (3 answers)
Closed 6 days ago.
create a sql query to display the last 5 records of the Sdelki table by Users.ID_user the Users table is linked to the Clients table by ID_User, and the Klients table is linked to the Sdelki table by ID_Klient
this query didn't work
SELECT Sdelki.*
FROM Sdelki
INNER JOIN Klients
ON Sdelki.ID_Klient = Klients.ID_Klient
INNER JOIN Users
ON Klients.ID_user = Users.ID_user
ORDER BY Sdelki.ID_sdelki DESC
LIMIT 5;
using SQL Server
2条答案
按热度按时间eoigrqb61#
Sql Server doesn't use
LIMIT
, it usesTOP
instead :juud5qan2#
You need to use
Klients.ID_user
orUsers.ID_user
in order by clause to get the expected results.This is the updated query
EDIT: removed
LIMIT 5
and usedTOP 5
in the query, since LIMIT isn't supported in SQL Server.