我想按照下面列出的顺序对以下数据项进行排序:
id msisdn locker is_selected classification nomor ---------------------------------------------------------------------- 1282 62811409xxx Kendari 0 1 01 1138 62811409xxx Kendari 0 1 01 3264 62811556xxx Samarinda 0 1 02 3323 62811562xxx Pontianak 0 1 02 3450 62811481xxx Jayapura 0 1 03 3435 62811481xxx Jayapura 0 1 03
查询:
(SELECT *, CONCAT(is_selected, 1) AS nomor FROM reference_number WHERE is_selected = 0 AND classification = 1 AND
LEFT(msisdn, 7) IN (6281140, 6281141, 6281142, 6281143, 6281144, 6281145, 6281146) ORDER BY RAND() LIMIT 2) UNION
(SELECT *, CONCAT(is_selected, 2) AS nomor FROM reference_number WHERE is_selected = 0 AND classification = 1 AND
LEFT(msisdn, 7) IN (6281150, 6281151, 6281152, 6281153, 6281154, 6281155, 6281156, 6281157, 6281158, 6281159)
ORDER BY RAND() LIMIT 2) UNION
(SELECT *, CONCAT(is_selected, 3) AS nomor FROM reference_number WHERE is_selected = 0 AND classification = 1
AND LEFT(msisdn, 7) IN (6281147, 6281148, 6281149)
ORDER BY RAND() LIMIT 2)
ORDER BY nomor
我希望输出是:
nomor ----- 01 02 03 01 02 03 01 02 03
有什么技巧让它更合适吗?
非常感谢!