Hiển thị các bài đăng có nhãn order null values. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn order null values. Hiển thị tất cả bài đăng

Mysql Order NULL value

Source: https://www.designcise.com/web/tutorial/how-to-order-null-values-first-or-last-in-mysql

In MySQL 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)

Sort In Ascending Order With NULLs Last

Using The Minus Operator:

In MySQL NULL values are considered lower in order than any non-NULL value, except if a - (minus) character is added before the column name while sorting.
Query:
SELECT * FROM user 

ORDER BY -date_login DESC

While this may work well for numbers and dates, it may not be the best solution to sort fields with alpha or alphanumeric values, for those you may want to try the other methods discussed in this article.

Renewing Facebook Graph API token automatically?

  Mã truy cập dài hạn https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived/ https://community.n8n.io/t/re...