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 6732099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:36:31+00:00 2026-05-26T10:36:31+00:00

I have to join 2 tables which are currently holding more than 200K data

  • 0

I have to join 2 tables which are currently holding more than 200K data each. I have members and orders table. I would like to get members who didn’t order anything.

I tried following SQL queries;

Structure (just listing what I need)

ORDERS                  MEMBERS
id                      id
member_id               fullName
                        email
                        landLine
                        cellPhone

Query1

$sql  = 'SELECT '.PREFIX.'members.fullName
           , '.PREFIX.'members.email
           , '.PREFIX.'members.landLine
           , '.PREFIX.'members.cellPhone, ';
$sql .= 'FROM '.PREFIX.'members';
$sql .= 'LEFT JOIN ';
$sql .= PREFIX.'orders';
$sql .= ' ON ';
$sql .= PREFIX.'members.id = '.PREFIX.'orders.member_id';
$sql .= ' WHERE '.PREFIX.'orders.member_id IS NULL LIMIT 50';

Query 2

$sql2  = 'select id, fullName, email, landLine, cellphone 
          from '.PREFIX.'members 
          where '.PREFIX.'members.id not in 
             (select member_id from '.PREFIX.'orders) 
          LIMIT 50';

Query 3

$sql3  = 'select id, fullName, email, landLine, cellphone 
          from '.PREFIX.'members m 
          where not exists 
            (select null from '.PREFIX.'orders o where s.members_id = o.id) 
          LIMIT 50';

All 3 queries so far didn’t work. More than a minute passed, I am still waiting for the results.

What is the most elegant way to do this? Which one is faster and using less resources? I don’t see anything wrong here why it would work but for some reason it just can’t list.

Thank you for your help in advance.

  • 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-26T10:36:31+00:00Added an answer on May 26, 2026 at 10:36 am

    I should try

    SELECT id, fullName, email, landLine, cellphone 
    FROM members
    WHERE id NOT IN
        (SELECT DISTINCT member_id FROM orders)
    LIMIT 50
    

    Be sure to put indexes on members.id and orders.member_id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have quite a messy query, which joins data from multiple tables involving
I have two tables which I want to join together using a left outer
I have a MySQL Left Join problem. I have three tables which I'm trying
I have a join which deletes rows that match another table but the joining
I have 3 tables I need to join. The contracts table is the main
I have three tables, table one (tableA) containing users data like name and email,
I currently have the following MySQL query, which I would like to include in
I currently have 3 tables, which I'm using for people to make reservations for
I have a model called Notifications, which basically acts as a join table between
I've got three tables which all join into one table. Here is the code:

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.