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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:30:24+00:00 2026-05-20T19:30:24+00:00

table1 id, name, desc 1, Abc, some desc 2, Def, more desc 4, Jkl,

  • 0
table1
id, name, desc

1, Abc, some desc
2, Def, more desc
4, Jkl, another desc

table2 
id, table1_id, title
1,  1, My title
2,  1, Another title
3,  3, Yet another title

Table 1 has row with id of 3 “missing”. But if you notice, there is one refernece to this missing id in table2. So my question is how do I select all rows of table2 which has references to table1_id(s) which no longer are availabe in table1??

I am not very good at mysql queries and tried something like …
SELECT b.* FROM table2 b INNER JOIN table1 a ON b.table1_id != a.id and some others but could not get the desired result.

Could you throw some idea how this can be achieved?
Thanks

  • 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-20T19:30:24+00:00Added an answer on May 20, 2026 at 7:30 pm
    SELECT b.*
    FROM table2 b
    LEFT JOIN table1 a ON b.table1_id = a.id
    WHERE a.id is null
    

    Just some minor changes, from INNER to LEFT OUTER, with the condition that a.id is null (no match found in table a).

    For deletes, use

    DELETE FROM table2
    WHERE table1_id not in (select id from table1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Table 1: id name desc ----------------------- 1 a abc 2 b def 3 c
I have the table Tb ID | Name | Desc ------------------------- 1 | Sample
If I have a table such as: info_name | info_value name | Susan desc
Table1: id - name 1 - john 2 - david 3 - dilio Table2:
After doing some joins and stuff I have table in the following format name
Table 1 -> id, name Table 2 -> id, name, text_value, table1_id, table3_id Table
How to return table name in the below mysql fulltext union search? (SELECT title,content,date
Hi i have a table structure like this. table **geoinfo** id name desc I
Lets say we a table t1 as >desc t1; id int name varchar(30) and
table1 has the columns: id name value event 1 name1 0.5 f 2 name2

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.