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

The Archive Base Latest Questions

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

Below is my Table Structure Table 1 id name Table 2 id table1_id I

  • 0

Below is my Table Structure

Table 1

id
name


Table 2

id
table1_id

I want the rows from table 1 which have no reference value in table 2.

Example data:

Table 1
id                name                       
1                  demo
2                  demo2
3                  demo3

Table 2

id                table1_id
1                   1
2                   1
3                   1
4                   3
5                   3

So there is no value in table 2 with table1_id 2. I want id 2 from Table 1.

Below id the query i have tried:

SELECT l.id FROM Table1 l WHERE l.id NOT IN (SELECT DISTINCT(r.id) FROM table2 r);

This is returning a proper result but its taking more than 2 minutes to process.

In table 1 i have 4000 rows and in table 2 I have 40000 rows.

Any optimisation to above query or any alternative solution?

  • 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-23T08:51:34+00:00Added an answer on May 23, 2026 at 8:51 am
    SELECT * FROM table1 LEFT JOIN table2
    ON table1.id=table2.table1_id
    WHERE table2.table1_id IS NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a organization name table with the following structure given below: CREATE TABLE
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a polygon structure in an sql2005 db as described below. CREATE TABLE
Based on the following data structure. CREATE TABLE [Parent] ( Id INT, Name nvarchar(100)
i'm using curl to retrieve a page which has a table structure as below.
I have following db structure in mysql. Table: Story Id Name categoryid date 1
i have a t_my_class table structure like below (MySql table) id class group age
i have the table below <tr id=group_1>...</tr> <tr id=el>...</tr> <tr id=el>...<tr> <tr id=group_2></tr> <tr
I have an SQL table defined as below: CREATE TABLE [TestComposite] ( ID int,
Below is my table, a User could have multiple profiles in certain languages, non-English

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.