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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:26:05+00:00 2026-06-09T23:26:05+00:00

I am using mysql and have 2 tables table1 id 324 325 328 350

  • 0

I am using mysql and have 2 tables

table1

id
324
325
328
350
420
650
850
950

table2

id    mapping_id
324   1
325   2
328   3
350   4
420   5
650   1
850   2

I want to produce a list of all the DISTINCT field mapping_ids that are missing for the ids in table one. For example id 850 has a mapping_id of 2 so is missing 1,3,4,5 and id 950 is not even in table 2 and so is missing 1,2,3,4,5. This should give me a distinct list of 1,2,3,4,5.

I have tried various LEFT JOIN queries but cannot get the results I need. Thanks 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-06-09T23:26:07+00:00Added an answer on June 9, 2026 at 11:26 pm

    You could build a matrix of id - mapping combinations using a cross join. A not in subquery can determine which parts of the matrix are empty:

    select  *
    from    table1 t1
    cross join
            (
            select  distinct mapping_id
            from    table2
            ) mappings
    where   not exists
            (
            select  *
            from    table2 t2
            where   t2.id = t1.id
                    and t2.mapping_id = mappings.mapping_id
            )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql db with several tables, let's call them Table1, Table2, etc.
I'm using MySQL I have three tables: accounts { account_id, username } account_ips {
using php and mysql I have two tables, a users table and a profiles
Using MySQL, I have three tables: projects : ID name 1 birthday party 2
I'm using MySQL 4.1. Some tables have duplicates entries that go against the constraints.
I'm using PHP/MySql. If I have two tables (hypothetically) as follows: id name and
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
Suppose I am building an app using current mysql database tables. I have this
Greetings, I have some mysql tables that are currently using an md5 hash as
I have two tables table1 and table2, i need to write a select query

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.