2010-04-28 13 views

risposta

432
SELECT * FROM Table_Name LIMIT 5; 
+0

+2 sia per la risposta corretta, sia per non includere le parentesi quadre non raffrontate. – DaveBoltman

20
select * from [Table_Name] limit 5 
+5

Un minuto troppo tardi e hai perso centinaia di voti – Todd

+1

o potresti perdere tutti i tappi – YOU

36

Una dichiarazione equivalente sarebbe

select * from [TableName] limit 5 

http://www.w3schools.com/sql/sql_top.asp

+0

Come fai a sapere che è ServiceLog? ;-) –

+0

è stato un mio errore. in seguito l'ho cambiato in [Table_Name] – Amitabh

+0

Ah, nessun mistero qui :-(;-) –

26

TOP e parentesi quadre sono specifici per Transact-SQL. In ANSI SQL si usa LIMIT e backtick (`).

select * from `Table_Name` LIMIT 5; 
+3

LIMIT non è ANSI SQL. La modalità ANSI SQL è SOLO FETCH FIRST 5 ROWS. Anche le doppie virgolette sono usate per gli identificatori delimitati, ad es. "Table_name". – jarlh

3
select * from [TABLE_NAME] limit 5 
16
select price from mobile_sales_details order by price desc limit 5 

Nota: ho mobile_sales_details tavolo

sintassi

select column_name from table_name order by column_name desc limit size. 

se avete bisogno di prezzo più alto basso è sufficiente rimuovere la parola disc dall'ordine da

2
Select TableName.* from TableName DESC LIMIT 5 
Problemi correlati