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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:27:27+00:00 2026-05-25T17:27:27+00:00

I have three tables called SData, Schdata and Fordata and the data looks like:

  • 0

I have three tables called SData, Schdata and Fordata and the data looks like:

SData:                    Schdata                     Fordata           

Name      Pro_ID          Pro_ID    Sch_ID         Str_ID    Sch_ID
ACase     258             258       438            6         654
Boece     369             125       125            7         438
Dremd     781             369       985            12        548
Wep       469             469       754            8         284


PQData

Pro_ID   Sch_ID   Type
258      438      rep
358      678      pro

Now I am trying to get the Names from SData where the Pro_ID exists in Schdata and I don’t want the Pro_ID from Schdata which has the Shc_ID from Fordata so My output should be:

Name    Sch_ID
Boece   985 
Wep     754

So I wrote a query something like this:

Select a.Name,s.Sch_ID 
From SData a
Inner Join Schdata s
on a.Pro_ID = s.Pro_ID
Inner Join Fordata f 
on f.Sch_ID <> s.Sch_ID

But I don’t know whether I am doing it right. can anyone help me?

  • 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-25T17:27:28+00:00Added an answer on May 25, 2026 at 5:27 pm

    One solution using OUTER/INNER JOINs:

    DECLARE @SData TABLE
    (
        Name VARCHAR(25) NOT NULL
        ,Pro_ID INT NOT NULL
    );
    INSERT  @SData 
    VALUES  ('ACase',258),('Boece',369),('Dremd',781),('Wep',469);
    
    DECLARE @Schdata TABLE
    (
        Pro_ID INT NOT NULL
        ,Sch_ID INT NOT NULL
    );
    INSERT  @Schdata 
    VALUES  (258,438), (125,125), (369,985), (469,754);
    
    DECLARE @Fordata TABLE
    (
        Str_ID INT NOT NULL
        ,Sch_ID INT NOT NULL
    );
    INSERT  @Fordata
    VALUES  (6,654), (7,438), (12,548), (8,284);
    
    SELECT  a.Name, b.Sch_ID
    FROM    @Schdata b
    LEFT OUTER JOIN @Fordata c ON b.Sch_ID = c.Sch_ID 
    INNER JOIN @SData a ON a.Pro_ID = b.Pro_ID 
    WHERE   c.Sch_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 three tables Pproject, ProjectMilestone and ReleaseSchedule. i want to add a derived
I have three tables/models. User, Alliance and Alliance_Membership. The latter is a join table
I currently have two tables, one is called games, the other called rounds. Here
If you have a table called posts, which contains id, title, content .etc, how
I'm making a small DataBase with MySQL Workbench. I have a main table, called
How do we build a profile page that outputs the user's data? and this
I'm developing an Android application with a database. That database will have more than
I'm fairly new to MySQL and don't know how to write a query I
I'm new to Entity Framework. I've created a Multi Tier Application, in MVC, using
Apologize for the long topic, I didn't intend for it to be this long,

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.