你可以在MySQL中使用parthesis来让它工作
CREATE tABLe customer ( `cust_id` int,`member` int,`date` datetime)
INSERT INTO customer
(`cust_id`, `member`, `date`)
VALUES
(25, 1, '2022-05-01 22:22:22'),
(30, 1, '2021-01-11 05:23:11'),
(31, 1, '2022-05-01 21:22:22'),
(32, 1, '2021-01-11 06:23:11'),
(50, 0, '2023-09-01 22:22:22'),
(49, 0, '2023-08-21 20:20:20'),
(46, 0, '2023-08-20 19:20:21'),
(50, 0, '2023-09-01 22:22:22'),
(51, 0, '2023-08-21 20:20:20'),
(52, 0, '2023-08-20 19:20:21')
;
Records: 10 Duplicates: 0 Warnings: 0
(SELECT `cust_id`,`member`,`date` FROM `customer` WHERE `member` = 1 ORDER BY `date` DESC LIMIT 10000000)
UNION
(SELECT `cust_id`,`member`,`date` FROM `customer` WHERE `member` = 0 ORDER BY `cust_id` DESC LIMIT 10000000)
|
cust_id
|
成员
|
日期
|
|
25
|
1.
|
2022-05-01 22:22:22
|
|
31
|
1.
|
2022-05-01 21:22:22
|
|
32
|
1.
|
2021-01-11 06:23:11
|
|
30
|
1.
|
2021-01-11 05:23:11
|
|
52
|
0
|
2023-08-20 19:20:21
|
|
51
|
0
|
2023-08-21 20:20:20
|
|
50
|
0
|
2023-09-01 22:22:22
|
|
49
|
0
|
2023-08-21 20:20:20
|
|
46
|
0
|
2023-08-20 19:20:21
|
fiddle