0
我有一個返回最近或最後插入廣告MySQL存儲過程的查詢
的發送的電子郵件以下存儲過程:「現在我的目的,只顯示其已在活動」派:計數大於‘0’如何更大可我更改以下SP做到這一點,因爲現在是返回所有的活動,包括「0」和大於「0」」 ..
代碼是...
DELIMITER $$
DROP PROCEDURE IF EXISTS `couponcrusaderdev`.`sp_tblemailcampaignLoadTop4`$$
CREATE DEFINER=`anyone`@`000.000.00.00` PROCEDURE `sp_tblemailcampaignLoadTop4`(p_UserID Int(11))
SQL SECURITY INVOKER
BEGIN
SELECT EC.*,(Select MailChimpCampaignID from tblcampaignschedule where EC.CampaignID=tblcampaignschedule.CampaignID) as MailChimpCampaignID,(Select count(MailChimpCampaignID) from tblcampaignschedule) as msent,CT.CampaignType, (Select tblcampaignschedule.ScheduleDateTime from tblcampaignschedule
where EC.CampaignID=tblcampaignschedule.CampaignID order By ScheduleDateTime desc limit 1) as CampaignDateTime,
(Select Count(*) from tblemailsent ES
inner join tblcampaignschedule CS on CS.CampaignSceduleID= ES.CampaignSceduleID
where ES.Status= 'ProcessedMessage' and CS.CampaignID = EC.CampaignID)as Sent
FROM tblemailcampaign EC
inner join tblcampalgntype CT on CT.CampaignTypeID= EC.CampaignTypeID
inner join tblcompanies C On EC.CompanyID = C.CompanyID
WHERE (p_UserID = 0 OR C.AddUserID = p_UserID)
order by CampaignDateTime desc limit 4
;
END$$
DELIMI
感謝回答,但我應該在哪裏把這個在紐約上面的代碼ü可以貼吧,我在上面的代碼,然後重新發送它... PLZ我是初學者以及下一行應該做什麼..........按CampaignDateTime的順序desc limit 4 –
在「order by」之前。 – Oyeme
以下行應該做什麼..........按CampaignDateTime desc limit 4的順序添加HAVING COUNT(sent)> = 0;它返回異常的結果,我認爲這是由於它 –