Details
-
New Feature
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
In MySQL/MariaDB NULL values are considered lower than any non-NULL
value, therefore, NULL values appear first when the order is ASC
(ascending), and ordered last when the order is DESC (descending).
MariaDB [(none)]> SELECT name FROM (SELECT 'Leipzig' AS name FROM dual UNION ALL SELECT NULL FROM dual UNION ALL SELECT 'Berlin' FROM dual) t ORDER BY name;
|
+---------+
|
| name |
|
+---------+
|
| NULL |
|
| Berlin |
|
| Leipzig |
|
+---------+
|
3 rows in set (0.001 sec)
|
Can we implement something like NULLS LAST so even if with order by esc, NULLs come last and not first?
Though for now there is some workaround like using order by with null.
MariaDB [(none)]> SELECT name FROM (SELECT 'Leipzig' AS name FROM dual UNION ALL SELECT NULL FROM dual UNION ALL SELECT 'Berlin' FROM dual) t ORDER BY name is null, name asc;
|
+---------+
|
| name |
|
+---------+
|
| Berlin |
|
| Leipzig |
|
| NULL |
|
+---------+
|
3 rows in set (0.001 sec)
|
|
Attachments
Issue Links
- is duplicated by
-
MDEV-33663 Different sort order regarding NULLs
- Closed