MySQL Custom sort order
Example: Adding an ORDER by FIELD (status,3,4,0,2,1) statement to a SQL statement defines the sort order
SELECTtsdvoucher0_. voucher_id asvoucher1_0_, Tsdvoucher0_.comment_device_type ascomment2_0_, tsdvoucher0_.comment_id ascomment3_0_, Tsdvoucher0_.comment_person_no ascomment4_0_, Tsdvoucher0_.comment_pic ascomment5_0_, tsdvoucher0_.comment_spending asComment6_0_, tsdvoucher0_. Create_time asCreate7_0_, tsdvoucher0_. Restaurant_context asRestaurant8_0_, tsdvoucher0_. restaurant_id asRestaurant9_0_, tsdvoucher0_. Restaurant_name asrestaurant10_0_, tsdvoucher0_.user_id asUser11_0_, tsdvoucher0_. VERSION asVersion0_, tsdvoucher0_. voucher_act_id asVoucher13_0_, tsdvoucher0_. Voucher_act_ratios asVoucher14_0_, tsdvoucher0_. Voucher_business_status asvoucher15_0_, tsdvoucher0_. Voucher_check_status asVoucher16_0_, tsdvoucher0_. Voucher_checked_time asVoucher17_0_, tsdvoucher0_. Voucher_denomination asVoucher18_0_, tsdvoucher0_. Voucher_pic asVoucher19_0_, tsdvoucher0_. Voucher_used_time asvoucher20_0_, tsdvoucher0_. Voucher_valid_day asvoucher21_0_ fromT_sd_voucher tsdvoucher0_WHEREtsdvoucher0_.user_id = ?ORDER byFIELD (tsdvoucher0_. Voucher_business_status,3,4,6,5), FIELD (tsdvoucher0_. Voucher_check_status,3,2,4), tsdvoucher0_. Create_timeASC
Description: Status is a sort field, followed by the related value of the field