4 ms·
Wouldn't a better analogy for SQL be 'Get the top two eggs from the fridge'? It'd translate to select top 2 eggs from fridge;
by Deukhoofd 3y ago
Wouldn't a better analogy for SQL be 'Get the top two eggs from the fridge'?
It'd translate to
select top 2 eggs from fridge;
- zaphirplane 3y agoSelect top(eggs) from fridge limit 2
- jorams 3y agoThat's not standard SQL. This was standardized pretty late, so different RDBMS have various syntaxes, but the standardized one is to add a clause like this: FETCH FIRST n ROWS ONLY In PostgreSQL and MySQL the usual syntax is a LIMIT clause, but PostgreSQL also supports the standard. MSSQL and some others use TOP n directly after SELECT. I think in some others you need to use a window function.
- LikesPwsh 3y agoTop n is even deprecated in mssql, in favor of top(n).