Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5961505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:58:26+00:00 2026-05-22T18:58:26+00:00

ms sql server 2008 SELECT Action.* FROM Mailing INNER JOIN ActionCategoryMailingBunch ON Mailing.MailingID =

  • 0

ms sql server 2008

enter image description here

SELECT Action.* 
FROM   Mailing 
       INNER JOIN ActionCategoryMailingBunch 
         ON Mailing.MailingID = ActionCategoryMailingBunch.MailingID 
       INNER JOIN ActionCategory 
         ON ActionCategoryMailingBunch.ActionCategoryID = 
            ActionCategory.ActionCategoryID 
       INNER JOIN Action 
         ON ActionCategory.ActionCategoryID = Action.ActionCategoryID 
WHERE  ( Mailing.MailingID = 7 ) 
       AND ( Mailing.MailingID NOT IN (SELECT MailingID 
                                       FROM   MailingReport) ) 
       AND ( Action.ActionID NOT IN (SELECT ActionID 
                                     FROM   MailingReport) ) 
       AND ( ActionCategoryMailingBunch.MailingBunchStatusID = 4 )  

especially this block

(Mailing.MailingID NOT IN (SELECT MailingID FROM  MailingReport)) 
AND (Action.ActionID NOT IN (SELECT ActionID FROM  MailingReport))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:58:27+00:00Added an answer on May 22, 2026 at 6:58 pm

    Add the below code in the select statement

    Left Join MailingReport MR on MR.ActionID = Mailing.MailingID
    

    Add the below code in Where clause

    (MR.ActionID is null)
    

    Performance upgrade due to following block

    (Mailing.MailingID NOT IN (SELECT MailingID FROM  MailingReport)) 
    

    Final Query

    SELECT Action.* 
    FROM   Mailing 
           INNER JOIN ActionCategoryMailingBunch 
             ON Mailing.MailingID = ActionCategoryMailingBunch.MailingID 
           INNER JOIN ActionCategory 
             ON ActionCategoryMailingBunch.ActionCategoryID = 
                ActionCategory.ActionCategoryID 
           INNER JOIN Action 
             ON ActionCategory.ActionCategoryID = Action.ActionCategoryID 
             Left Join MailingReport MR on MR.ActionID = Mailing.MailingID
    WHERE  ( Mailing.MailingID = 7 ) 
           --AND ( Mailing.MailingID NOT IN (SELECT MailingID 
           --                                FROM   MailingReport) ) 
           AND
           (MR.ActionID is null)
           AND ( Action.ActionID NOT IN (SELECT ActionID 
                                         FROM   MailingReport) ) 
           AND ( ActionCategoryMailingBunch.MailingBunchStatusID = 4 ) 
    

    Similarly you can do for the second block
    Performance due to second block

    AND (Action.ActionID NOT IN (SELECT ActionID FROM  MailingReport))
    

    Final Query for both blocks

    SELECT Action.* 
    FROM   Mailing 
           INNER JOIN ActionCategoryMailingBunch 
             ON Mailing.MailingID = ActionCategoryMailingBunch.MailingID 
           INNER JOIN ActionCategory 
             ON ActionCategoryMailingBunch.ActionCategoryID = 
                ActionCategory.ActionCategoryID 
           INNER JOIN Action 
             ON ActionCategory.ActionCategoryID = Action.ActionCategoryID 
             Left Join MailingReport MR on MR.ActionID = Mailing.MailingID
             Left Join MailingReport MRA on MRA.ActionID = Action.ActionID
    WHERE  ( Mailing.MailingID = 7 ) 
           AND
           (MR.ActionID is null)
           AND
           (MRA.ActionID is null)
           AND ( ActionCategoryMailingBunch.MailingBunchStatusID = 4 ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SQL Server 2008 and I need to select all data from
Sql Server Management Studio 2008 is not scripting table permissions even when I select
In SQL Server 2008, select * from OneTable compare to select * from OneTable
I have a SQL Server 2008 query SELECT TOP 10 * FROM T WHERE
I’m trying to select various table and column names from a (SQL Server 2008)
Here's the query that is being executed on SQL Server 2008: SELECT "dbo"."tblMainData"."recID" FROM
Consider the following SQL Server 2005/2008 query: Select [UID], [DESC] From SomeTable Order By
Why is this query not working in Sql Server 2008? Select Top @PageSize Skip
I can list all views in SQL Server 2008 by using SELECT * FROM
Warning, ugly query alert (MS SQL Server 2008): SELECT BaseDocs.* FROM ( SELECT ROW_NUMBER()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.