In short, it’s implementation-dependant. See:
- https://dba.stackexchange.com/questions/6051/what-is-the-default-order-of-records-for-a-select-statement-in-mysql
- https://stackoverflow.com/questions/60293373/how-order-by-ordered-if-they-are-same-value
The MySQL 8 ref manual here also stated that:
On character type columns, sorting—like all other comparison operations—is normally performed in a case-insensitive fashion. This
means that the order is undefined for columns that are identical
except for their case. You can force a case-sensitive sort for a
column by usingBINARY
like so:ORDER BY BINARY col_name
.
A second column can be specified, e.g. ORDER BY wp_posts.post_date DESC, wp_posts.ID DESC
, but WordPress doesn’t do that by default.
I made a demo on DB Fiddle which demonstrates the above “normally performed in a case-insensitive fashion” and the “2nd column” thing.
- At the time of writing, DB Fiddle seemed to be using the PK (primary key) column to sort columns that are identical (see Query #1 in another demo here). My test site also seemed to be doing the same (🤔), see screenshot 1 and screenshot 2.
So, that might also be the case with your RDBMS/hosting, but you would need to consult your hosting support regarding that.