Pregunta

If I wrote this in MySQL

SELECT * FROM foo ORDER BY bar LIMIT 1

it would first order the result and limit it afterwards. I always get the lowest bar.

I wonder if this is specified like this in SQL-standards and how to check that?

All I found are some BNF's which do not explain how something should work, but only what syntax is valid.

¿Fue útil?

Solución

SQL 99 has no LIMIT. That is an extension in MySQL (and few other databases) initially created by PHP's founder Rasmus Lerdorf.

SQL 2003 added support for a comparable OFFSET sytnax of this form:

SELECT ... [ ORDER BY ... ]
   OFFSET num {ROW|ROWS} FETCH {FIRST|NEXT} [num] {ROW|ROWS} ONLY

Not sure any RDMBS supports that, yet.

For checking such features you can buy the standard from ISO. But as most databases implement things slightly of standard. In practical terms you will do better by checking the manuals of the systems you want to support and proper testing of your application.

Licenciado bajo: CC-BY-SA con atribución
scroll top