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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:54:30+00:00 2026-05-25T00:54:30+00:00

I need to fetch data from two tables For example: I have tables test1,

  • 0

I need to fetch data from two tables

For example: I have tables test1, test2. Test1 is the parent table. I need to fetch data is that present in test1 but not in test2. How can I write a query for that?

select id from test1, test2 where test1.id not in (test2.id);
  • 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-25T00:54:31+00:00Added an answer on May 25, 2026 at 12:54 am

    Do an LEFT OUTER JOIN: this will, for each line in table 1 find the corresponding line(s) in table2 – but the LEFT OUTER will cause it to return the line with NULLs for the table2 values when no values are found. Then, just ask those where the table2 fields are NULL (hence do not exist).

    select id from test1
    LEFT OUTER JOIN test2 
    ON test1.id = test2.id
    where test2.id IS NULL
    

    You could try a subquery too, but this will not perform better (usually worse):

    SELECT id FROM test1 
    WHERE id NOT IN (select id from test2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables that I want to fetch data from. Lets call them
Im using vb.net and I need to fetch data from two different tables and
I need a query that loops data from two tables. The two tables I
I've got two tables from which I need to extract information, but the data
Need to fetch data from a few tables -table one has all product details
I want to fetch a data from two tables even if the second table
What do I do, I need to fetch data from 3 tables in mysql,
I have the following Query and i need the query to fetch data from
I have a script that grabs data from a MySQL database table and creates
I'm using join to query data from two tables. For each a_id I need

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.