3 ms·
I’ve long felt that SQL was somehow backwards, but I don’t know what would be better. ‘Go and get two eggs’ Is better than ‘go to the fridge and get eggs, only
by hsbauauvhabzb 4y ago
I’ve long felt that SQL was somehow backwards, but I don’t know what would be better. ‘Go and get two eggs’ Is better than ‘go to the fridge and get eggs, only two’.
- masklinn 4y ago> but I don’t know what would be better. Strictly following the semantics order of the querying, whether forward or reverse. The ordering issue of SQL is that it uses a mixed ordering, the physical layout of the query in text form doesn’t follow the logical execution of the query, which makes it very confusing. Comparing to short cutesy sentences is not helpful as a non-trivial query has dozens or hundreds of steps, it’s closer to a build book or checklist. Furthermore english is far from a paragon of clarity or regularity, and languages which try to follow it (SQL, AppleScript) tend to scale a lot worse with instruction sizes and complexity.
- afiori 4y agoAfter using moonshine MongoDB pipelines I would say that it is a fantastic model. You can sort of already do this in SQL with CTE* but a nice pipeline syntax would be welcome. * Actually I believe that you can do more with CTE as you can mix the various steps in arbitrary ways
- Deukhoofd 4y agoWouldn'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 4y agoSelect top(eggs) from fridge limit 2
- jorams 4y 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 4y agoTop n is even deprecated in mssql, in favor of top(n).