Order by sorting is the most commonly used feature, but sorting can sometimes encounter null NULL in the case of data, so the sorting will be messy, here in MySQL as an example, to record the problems I encountered and solve ideas.
Problem:
Page to implement table row mouse Drag sort, I used angularjs integrated with a TABLEDND open source plug-in, can be implemented, and then add a sort field IndexID in the database table, but the original large amount of data is not sorted, so the field is null.
When the order is done, the null data will be in the front row.
Write a test sheet to simulate the following effects:
Workaround:
Best practices: Use a small trick in MySQL, precede the field with a minus sign, minus sign, ASC to DESC, DESC to ASC
Regenerate a column, such as Agenull, with the IS null operator, change the row of the null value to 1, the non-null value of the row to 0, sort the field first, and then sort the age
Methods also try databases such as SQL Server and Oracle
When ordering by order in MySQL, the data exists null to do