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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:33:41+00:00 2026-05-18T08:33:41+00:00

I have two tables one named Person , which contains columns ID and Name

  • 0

I have two tables one named Person, which contains columns ID and Name and the second one, named Relation, which contains two columns, each of which contains an ID of a Person. It’s about a relation between customer and serviceman. I’d like to Join these two tables so that I’ll have names of people in every relation. Is it possible to write this query with some kind of joining?

EDIT::

I must do something wrong, but it’s not working. I had tried a lot of forms of so looking queries, but I had been only getting one column or some errors. It’s actually the school task, I have it already done (with different JOIN query). Firstly I had been trying to do this, but I’d failed: It seems to be very common situation, so I don’t know why it’s too complicated for me..

Here are my tables:

CREATE TABLE Oprava..(Repair) (  
  KodPodvozku INTEGER PRIMARY KEY REFERENCES Automobil(KodPodvozku),  
  IDzakaznika..(IDcustomer) INTEGER REFERENCES Osoba(ID),  
  IDzamestnance..(IDemployee) INTEGER REFERENCES Osoba(ID)  
);

CREATE TABLE Osoba..(Person) (  
  ID INTEGER CONSTRAINT primaryKeyOsoba PRIMARY KEY ,  
  Jmeno..(Name) VARCHAR(256) NOT NULL,  
  OP INTEGER UNIQUE NOT NULL  
);

It’s in Czech, but the words in brackets after “..” are english equivalents.
PS: I am using Oracle SQL.

  • 1 1 Answer
  • 3 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-18T08:33:41+00:00Added an answer on May 18, 2026 at 8:33 am

    Assuming your tables are:

    persons:   (id, name)
    relations: (customer_id, serviceman_id)
    

    Using standard SQL:

    SELECT p1.name AS customer_name, 
           p2.name AS serviceman_name
    FROM persons p1 
         JOIN relations ON p1.id=relations.customer_id
         JOIN persons p2 ON relations.serviceman_d=p2.id;
    

    Further explanation

    The join creates the following table:

    p1.id|p1.name|relations.customer_id|relations.serviceman_id|p2.id|p2.name
    

    Where p1.id=relations.customer_id, and p2.id=relations.serviceman_id. The SELECT clause chooses only the names from the JOIN.

    Note that if all the ids from relations are also in persons, the result size would be exactly the size of the relations table. You might want to add a foreign key to verify that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models: Person and Relation. The second one stores information about relations
I have two tables, DH_MASTER and DH_ALIAS . DH_MASTER contains information about a person,
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables, one Company and one Employee: class Company(models.Model): name = models.CharField(max_length=60)
Quick method description: I have two tables, lets name them table ONE and table
i have two tables one is called addons and holds information about different addons,
I have two tables. One contains information on hotels, added to my website by
I have two tables. One contains information on hotels, added to my website by
I have two tables called Person and Address . These tables I mapped one
I have two tables in a database one named purchases and one named items

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.