MySQL中使用union all获得并集的排序
时间:2021-07-01 10:21:17
帮助过:5人阅读
PROMOTE_ID,
SEQUENCE_ID,
PROMOTE_STATUS,
PROMOTE_TITLE,
RELEASE_DATE
FROM (
(SELECT
PROMOTE_ID,
SEQUENCE_ID,
PROMOTE_STATUS,
PROMOTE_TITLE,
RELEASE_DATE
FROM SYS_TEXT_PROMOTE
WHERE
ENABLED_FLAG = ‘1‘
AND PROMOTE_STATUS
=1
AND SORT_ID
= #{params.sortId}
order by SEQUENCE_ID
DESC,LAST_UPDATE_DATE
DESC) a)
union all
select
PROMOTE_ID,
SEQUENCE_ID,
PROMOTE_STATUS,
PROMOTE_TITLE,
RELEASE_DATE
FROM (
(SELECT
PROMOTE_ID,
SEQUENCE_ID,
PROMOTE_STATUS,
PROMOTE_TITLE,
RELEASE_DATE
FROM SYS_TEXT_PROMOTE
WHERE
ENABLED_FLAG = ‘1‘
AND PROMOTE_STATUS
=2
AND SORT_ID
= #{params.sortId}
order by RELEASE_DATE
DESC,LAST_UPDATE_DATE
DESC) b)
union all
select
PROMOTE_ID,
SEQUENCE_ID,
PROMOTE_STATUS,
PROMOTE_TITLE,
RELEASE_DATE
FROM (
(SELECT
PROMOTE_ID,
SEQUENCE_ID,
PROMOTE_STATUS,
PROMOTE_TITLE,
RELEASE_DATE
FROM SYS_TEXT_PROMOTE
WHERE
ENABLED_FLAG = ‘1‘
AND PROMOTE_STATUS
=0
AND SORT_ID
= #{params.sortId}
order by RELEASE_DATE
DESC,LAST_UPDATE_DATE
DESC) c)
MySQL中使用union all获得并集的排序
标签:title status ram release 情况 思路 enabled 存储 col