Mysql常見(jiàn)注意事項(xiàng)小記
-
Mysql常見(jiàn)注意事項(xiàng)小記
1. 排序問(wèn)題
正常如果按照某字段升序排列,空值會(huì)排到有值的前面;如果逆序排序空值排在最后。
有時(shí)候我們需要該字段為空的行數(shù)據(jù)要排到最后面去,這時(shí)只需要:
order by second_parent_name is null, second_parent_name, user_name
-
正常如果按照某字段升序排列,空值會(huì)排到有值的前面;如果逆序排序空值排在最后。
有時(shí)候我們需要該字段為空的行數(shù)據(jù)要排到最后面去,這時(shí)只需要:
order by second_parent_name is null, second_parent_name, user_name