3 ms·
It does not guarantee it. A select without a order by clause is not guaranteed to be in a repeatable or consistent order, neither in SQL nor MySQL. MySQL does
by tveita 13y ago
It does not guarantee it. A select without a order by clause is not guaranteed to be in a repeatable or consistent order, neither in SQL nor MySQL.
MySQL does have an implicit ordering on GROUP BY queries, but it is deprecated and should not be relied on.
- chris_wot 13y agoIt always amazes me how many people don't know that there is no guaranteed repeatable order in a select statement without an order by clause.
- ajanuary 13y agoThe problem is compounded by the fact that with the small data sets people tend to use to test during development, things are usually returned in insertion order.
- chris_wot 13y agoOh, it can often be worse. People sometimes try to do tricky things like running totals by relying on implicit order in SQL queries. Often they are trying to squeeze as much performance out of the database server as possible (usually SQL Server) by avoiding cursors. My favourite ever SQL Server hack was one done by a guy called Jeff Moden, who came up with a running total update that relied on a specific quirk of SQL Server clustered indexes. The amount of effort he put into it is quite remarkable! [1] 1. (Create a temp account to check it out, they're not spammers) http://www.sqlservercentral.com/articles/T-SQL/68467/ http://www.sqlservercentral.com/articles/T-SQL/68467/