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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:13:56+00:00 2026-05-17T02:13:56+00:00

i have following tables T1 ==== ====== ID Desc ==== ====== 1 t1 2

  • 0

i have following tables

T1    
    ====   ======
     ID     Desc
    ====   ======
     1       t1
     2       t2
     3       t3
     4       t4


T2
=====   =======  ========
 ID      T1ID     PT1ID
=====    ======  =========
 1        2         1
 2        3         2

In T2 both T1ID and PT1ID are foreign key for T1. In my output i want row with ID=4 as it does not have any matching row in both foreign key columns

  • 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-17T02:13:57+00:00Added an answer on May 17, 2026 at 2:13 am

    This should do want you want:

    var notInT2 = T1.Where(i => T2.All(e => e.T1ID != i.Id) &&
                                T2.All(e => e.PT1ID != i.Id));
    

    To test it:

    class RowT1 { public Int32 Id;}
    class RowT2 { public Int32 T1ID; public Int32 PT1ID;    }
    
    class Programm
    {
        static void Main()
        {
            var T1 = new List<RowT1>(){new RowT1(){Id=1},
                                       new RowT1(){Id=2},
                                       new RowT1(){Id=3},
                                       new RowT1(){Id=4}};
    
            var T2 = new List<RowT2>(){new RowT2(){T1ID=2, PT1ID=1}, 
                                       new RowT2(){T1ID=3, PT1ID=2}};
    
            var notInT2 = T1.Where(i => T2.All(e => e.T1ID != i.Id) &&
                                        T2.All(e => e.PT1ID != i.Id));
    
            Console.ReadLine();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following tables. I want to run a query but I think
I have 2 tables: comments & blog blog has the following fields: id(Unique key),title,
Not sure Looking for some guidance here... I have the following tables: site_text id
Suppose I have the following tables: CREATE TABLE Game ( GameID INT UNSIGNED NOT
I have the following MySQL tables: CREATE TABLE IF NOT EXISTS `conversations` ( `id`
I have the following query which allows me to join two tables by row
My problem is the following: I have two tables; persons and teams, I want
I have following tables questions -> id, question_data, user_id users -> id, fname, lname
Suppose that we have following tables create table Employee( 2 EMPNO NUMBER(3), 3 ENAME
I have the following tables: users +----------+----------+----------+ | id | name | dob |

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.