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

  • SEARCH
  • Home
  • 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 6015559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:51:11+00:00 2026-05-23T02:51:11+00:00

I try to avoid subqueries due to the fact they usually have much lower

  • 0

I try to avoid subqueries due to the fact they usually have much lower performance than a proper join.

This is my current NOT working query:

SELECT 
    a.`email_list_id`, a.`category_id`, a.`name`
FROM 
    `email_lists`AS a 
    LEFT JOIN `email_autoresponders` AS b 
        ON ( a.`website_id` = b.`website_id` ) 
WHERE 
    a.`website_id` = [...]
    AND a.`category_id` <> 0 
    AND a.`email_list_id` <> b.`email_list_id` 
GROUP BY 
    a.`email_list_id` 
ORDER BY a.`name`

This query works:

SELECT 
    `email_list_id`, `category_id`, `name` 
FROM 
    `email_lists` 
WHERE 
    `website_id` = [...] 
    AND `category_id` <> 0 
    AND `email_list_id` NOT IN ( 
        SELECT 
            `email_list_id` 
        FROM 
            `email_autoresponders` 
        WHERE `website_id` = [...] 
    ) 
GROUP BY 
    `email_list_id` 
ORDER BY 
    `name` 

Is there any way to do this with a left join? I’ve tried a number of different options.

  • 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-23T02:51:11+00:00Added an answer on May 23, 2026 at 2:51 am

    After rethinking it a bit, this might work i believe:

    SELECT 
        a.`email_list_id`, a.`category_id`, a.`name`
    FROM 
        `email_lists`AS a 
        LEFT JOIN `email_autoresponders` AS b 
            ON ( a.`website_id` = b.`website_id` and a.`email_list_id` = b.`email_list_id` ) 
    WHERE 
        a.`website_id` = [...]
        AND a.`category_id` <> 0 
        AND b.`email_list_id` is NULL
    GROUP BY 
        a.`email_list_id` 
    ORDER BY a.`name`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I always try to avoid to return string literals, because I fear they aren't
I try to avoid doing Count( ) because of performance issue. (i.e. SELECT COUNT(
I'll try to avoid describing the background here. I now have a query result
I try to avoid using static classes in my production code as they cant
I was reading this: Guideline Number 7: Try to avoid using unecessary classes and
I normally try to avoid duplication and adhere to the DRY principle. However, I'm
I know that cursors are frowned upon and I try to avoid their use
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
is there a better way to write this SQL than using WHERE ... IN
I try to avoid global statements in python and Do you use the "global"

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.