SELECT ACCOUNT_NO,USER_ID,BATCH_ID,PACK_ID,RECIPIENT_MSISDN,SENT_TIME,CONTENT,STATUS,RESPONSE_TIME,DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,MID FROM (
(SELECT SO.ACCOUNT_NO,SO.USER_ID,SO.BATCH_ID,SO.PACK_ID,SO.DEST_ADDR AS RECIPIENT_MSISDN,SO.SUBMIT_TIME AS SENT_TIME,SO.CONTENT,SO.STATUS,SO.RESPONSE_TIME,SO.DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SO.SRC_ADDR AS SENDER_NO,CONCAT('SMS',SO.BATCH_ID) AS CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,SMS_ID AS MID FROM b3_SMS_OUTBOX SO LEFT JOIN (SELECT ACCOUNT_NO,USER_ID,BATCH_ID,PACK_ID,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,ALPHA_SENDER_NO,SMART_FILTERING,CAMPAIGN_TYPE,'SMS' AS MESSAGE_TYPE FROM BATCH_SMS) s ON SO.ACCOUNT_NO=s.ACCOUNT_NO AND SO.USER_ID=s.USER_ID AND SO.BATCH_ID = s.BATCH_ID AND SO.PACK_ID = s.PACK_ID )
UNION ALL
(SELECT MO.ACCOUNT_NO,MO.USER_ID,MO.BATCH_ID,1,MO.RECIPIENT_MSISDN,MO.SENT_TIME,MO.CONTENT,MO.STATUS,MO.DELIVERY_TIME,MO.DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,MO.SENDER_NO,CONCAT('MMS',MO.BATCH_ID) AS CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,MMS_ID AS MID FROM b3_MMS_OUTBOX MO LEFT JOIN (SELECT ACCOUNT_NO,USER_ID,BATCH_ID,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,ALPHA_SENDER_NO,SMART_FILTERING,CAMPAIGN_TYPE,'MMS' AS MESSAGE_TYPE FROM BATCH_MMS) M ON MO.ACCOUNT_NO=M.ACCOUNT_NO AND MO.USER_ID=M.USER_ID AND MO.BATCH_ID = M.BATCH_ID )
UNION ALL
(SELECT SOB.ACCOUNT_NO,SOB.USER_ID,SOB.BATCH_ID,SOB.PACK_ID,SOB.DEST_ADDR AS RECIPIENT_MSISDN,SOB.SUBMIT_TIME AS SENT_TIME,SOB.CONTENT,SOB.STATUS,SOB.RESPONSE_TIME,SOB.DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SOB.SRC_ADDR AS SENDER_NO,CONCAT('SMS',SOB.BATCH_ID) AS CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,SMS_ID AS MID FROM SMS_OUTBOX SOB LEFT JOIN (SELECT ACCOUNT_NO,USER_ID,BATCH_ID,PACK_ID,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,ALPHA_SENDER_NO,SMART_FILTERING,CAMPAIGN_TYPE,'SMS' AS MESSAGE_TYPE FROM BATCH_SMS) s ON SOB.ACCOUNT_NO=s.ACCOUNT_NO AND SOB.USER_ID=s.USER_ID AND SOB.BATCH_ID = s.BATCH_ID AND SOB.PACK_ID = s.PACK_ID )
UNION ALL
(SELECT MOB.ACCOUNT_NO,MOB.USER_ID,MOB.BATCH_ID,1,MOB.RECIPIENT_MSISDN,MOB.SENT_TIME,MOB.CONTENT,MOB.STATUS,MOB.DELIVERY_TIME,MOB.DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,MOB.SENDER_NO,CONCAT('MMS',MOB.BATCH_ID) AS CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,MMS_ID AS MID FROM MMS_OUTBOX MOB LEFT JOIN (SELECT ACCOUNT_NO,USER_ID,BATCH_ID,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,ALPHA_SENDER_NO,SMART_FILTERING,CAMPAIGN_TYPE,'MMS' AS MESSAGE_TYPE FROM BATCH_MMS) M ON MOB.ACCOUNT_NO=M.ACCOUNT_NO AND MOB.USER_ID=M.USER_ID AND MOB.BATCH_ID = M.BATCH_ID )
) SEARCHSECTION WHERE MOB.ACCOUNT_NO = 'b3' and STATUS in ('S','D','F') AND SENT_TIME >= '2019-03-18 00:00:00' AND RECIPIENT_MSISDN = '85261234564' AND MOB.BATCH_ID IN (SELECT BATCH_ID FROM BATCH_MMS where ACCOUNT_NO = 'b3' AND TITLE LIKE '%sms 0314%') ORDER BY BATCH_ID DESC, PACK_ID, MID LIMIT 0,15
SELECT ACCOUNT_NO,USER_ID,BATCH_ID,PACK_ID,RECIPIENT_MSISDN,SENT_TIME,CONTENT,STATUS,RESPONSE_TIME,DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,MID FROM (
(SELECT SO.ACCOUNT_NO,SO.USER_ID,SO.BATCH_ID,SO.PACK_ID,SO.DEST_ADDR AS RECIPIENT_MSISDN,SO.SUBMIT_TIME AS SENT_TIME,SO.CONTENT,SO.STATUS,SO.RESPONSE_TIME,SO.DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SO.SRC_ADDR AS SENDER_NO,CONCAT('SMS',SO.BATCH_ID) AS CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,SMS_ID AS MID FROM b3_SMS_OUTBOX SO LEFT JOIN (SELECT ACCOUNT_NO,USER_ID,BATCH_ID,PACK_ID,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,ALPHA_SENDER_NO,SMART_FILTERING,CAMPAIGN_TYPE,'SMS' AS MESSAGE_TYPE FROM BATCH_SMS) s ON SO.ACCOUNT_NO=s.ACCOUNT_NO AND SO.USER_ID=s.USER_ID AND SO.BATCH_ID = s.BATCH_ID AND SO.PACK_ID = s.PACK_ID WHERE SO.ACCOUNT_NO = 'b3' and STATUS in ('S','D','F') AND SUBMIT_TIME >= '2019-03-18 00:00:00' AND DEST_ADDR = '85261234564' AND SO.BATCH_ID IN (SELECT BATCH_ID FROM BATCH_SMS where ACCOUNT_NO = 'b3' AND TITLE LIKE '%sms 0314%') )
UNION ALL
(SELECT MO.ACCOUNT_NO,MO.USER_ID,MO.BATCH_ID,1,MO.RECIPIENT_MSISDN,MO.SENT_TIME,MO.CONTENT,MO.STATUS,MO.DELIVERY_TIME,MO.DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,MO.SENDER_NO,CONCAT('MMS',MO.BATCH_ID) AS CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,MMS_ID AS MID FROM b3_MMS_OUTBOX MO LEFT JOIN (SELECT ACCOUNT_NO,USER_ID,BATCH_ID,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,ALPHA_SENDER_NO,SMART_FILTERING,CAMPAIGN_TYPE,'MMS' AS MESSAGE_TYPE FROM BATCH_MMS) M ON MO.ACCOUNT_NO=M.ACCOUNT_NO AND MO.USER_ID=M.USER_ID AND MO.BATCH_ID = M.BATCH_ID WHERE MO.ACCOUNT_NO = 'b3' and STATUS in ('S','D','F') AND SENT_TIME >= '2019-03-18 00:00:00' AND RECIPIENT_MSISDN = '85261234564' AND MO.BATCH_ID IN (SELECT BATCH_ID FROM BATCH_MMS where ACCOUNT_NO = 'b3' and TITLE LIKE '%sms 0314%') )
UNION ALL
(SELECT SOB.ACCOUNT_NO,SOB.USER_ID,SOB.BATCH_ID,SOB.PACK_ID,SOB.DEST_ADDR AS RECIPIENT_MSISDN,SOB.SUBMIT_TIME AS SENT_TIME,SOB.CONTENT,SOB.STATUS,SOB.RESPONSE_TIME,SOB.DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SOB.SRC_ADDR AS SENDER_NO,CONCAT('SMS',SOB.BATCH_ID) AS CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,SMS_ID AS MID FROM SMS_OUTBOX SOB LEFT JOIN (SELECT ACCOUNT_NO,USER_ID,BATCH_ID,PACK_ID,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,ALPHA_SENDER_NO,SMART_FILTERING,CAMPAIGN_TYPE,'SMS' AS MESSAGE_TYPE FROM BATCH_SMS) s ON SOB.ACCOUNT_NO=s.ACCOUNT_NO AND SOB.USER_ID=s.USER_ID AND SOB.BATCH_ID = s.BATCH_ID AND SOB.PACK_ID = s.PACK_ID WHERE SOB.ACCOUNT_NO = 'b3' and STATUS in ('S','D','F') AND SUBMIT_TIME >= '2019-03-18 00:00:00' AND DEST_ADDR = '85261234564' AND SOB.BATCH_ID IN (SELECT BATCH_ID FROM BATCH_SMS where ACCOUNT_NO = 'b3' AND TITLE LIKE '%sms 0314%') )
UNION ALL
(SELECT MOB.ACCOUNT_NO,MOB.USER_ID,MOB.BATCH_ID,1,MOB.RECIPIENT_MSISDN,MOB.SENT_TIME,MOB.CONTENT,MOB.STATUS,MOB.DELIVERY_TIME,MOB.DONE_TIME,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,MOB.SENDER_NO,CONCAT('MMS',MOB.BATCH_ID) AS CAMPAIGN_ID,CAMPAIGN_TYPE,MESSAGE_TYPE,MMS_ID AS MID FROM MMS_OUTBOX MOB LEFT JOIN (SELECT ACCOUNT_NO,USER_ID,BATCH_ID,TITLE,SCHEDULED_TIME,SCHEDULING_STATUS,SENDER_NO,ALPHA_SENDER_NO,SMART_FILTERING,CAMPAIGN_TYPE,'MMS' AS MESSAGE_TYPE FROM BATCH_MMS) M ON MOB.ACCOUNT_NO=M.ACCOUNT_NO AND MOB.USER_ID=M.USER_ID AND MOB.BATCH_ID = M.BATCH_ID WHERE MOB.ACCOUNT_NO = 'b3' and STATUS in ('S','D','F') AND SENT_TIME >= '2019-03-18 00:00:00' AND RECIPIENT_MSISDN = '85261234564' AND MOB.BATCH_ID IN (SELECT BATCH_ID FROM BATCH_MMS where ACCOUNT_NO = 'b3' AND TITLE LIKE '%sms 0314%') )
) SEARCHSECTION ORDER BY BATCH_ID DESC, PACK_ID, MID LIMIT 0,15
版权声明:本文为博主原创文章,转载请注明出处。
https://blog.csdn.net/jim_LoveQ/article/details/88820347