mysql unionall的一种使用方法

 SELECT
*
FROM
((
SELECT
NotificationBase.ID 通知ID,
NotificationDistributed.DistributionState 通知状态
FROM
NotificationBase
LEFT JOIN NotificationDistributed ON NotificationBase.ID 
 = NotificationDistributed.NotificationID
WHERE
NotificationDistributed.Receiver = '282b4fa100920146eb8c519892d6066310104469740cee8d12'
)
UNION ALL
(
SELECT
NotificationBase.ID  通知ID,
NotificationBase.ATTR8 通知状态
FROM
NotificationBase 
LEFT JOIN NotificationAttachment ON NotificationBase.ID 
 = NotificationAttachment.NotificationID
WHERE
NotificationBase.NotificationType IN (
'公告-公告'
)
AND NotificationBase.YouthLeague IN (
'JXW-001-032-008'
)
)
) A
ORDER BY
发布时间 DESC
LIMIT 10

猜你喜欢

转载自blog.csdn.net/weibin_6388/article/details/78457482
今日推荐