2013-07-06 4 views
8

mam ten skrypt MySQL:SELECT TOP błąd

SELECT TOP 2 * FROM produse ORDER BY `id_produs` DESC 

Generuje ten błąd:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2 * FROM produse ORDER BY `id_produs` DESC LIMIT 0, 30' at line 1 

czym polega problem?

+2

Jak trudne to może być to wyglądać w instrukcji? –

Odpowiedz

18

nie ma TOP w mysql

użycie LIMIT 2

SELECT * FROM produse ORDER BY id_produs DESC LIMIT 2 
5

Zastosowanie LIMIT zamiast:

SELECT * 
FROM produse 
ORDER BY id_produs DESC 
LIMIT 2