1. 程式人生 > >踩坑經歷三(三)SQL特殊排序處理

踩坑經歷三(三)SQL特殊排序處理

需求:2排最前面,null排最後

問題解決:IFNULL()函式 和 FIND_IN_SET()函式


select  id, organization_name, organization_code, cell_phone_number, plane_number, mailbox, 
    apply_contact_name, type_of_mechanism, registration_area, business_licence, main_account_application, 
    org_code_scann, other_accessories,registration_time,
			  IFNULL(re_state,9) orderfiled
		,reasons_correction,password
		from e_user_registry r
		order by  FIND_IN_SET(orderfiled,'2,1,3,9') ,registration_time DESC