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

  • Home
  • SEARCH
  • 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 907181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:30:42+00:00 2026-05-15T16:30:42+00:00

Given 2 base tables, 1 table which stores the relation between them with a

  • 0

Given 2 base tables, 1 table which stores the relation between them with a few extra attributes; taking a few extra attribute values as user input, based on that extracting relation from relation table.

This information has the ID of the main values (person and animal) not the names. I want to display the names on screen, like according to the input you gave the records which found are this person has this animal with him.

    select DISTINCT table0.person_name, table5.animal_name 
      from table1

 INNER JOIN table0, table5 
        on table1.person_id=table0.person_id
            and
        table1.animal_id=table5.animal_id

where table1.aa=input1 
       and table1.bb=input2 
       and table1.cc=input3 
       and table1.dd=input4
  • 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-15T16:30:42+00:00Added an answer on May 15, 2026 at 4:30 pm

    You have at least three errors.

    • The WHERE clause should come after the JOIN .. ON clause, not before it.
    • You cannot refer to columns in table5 because it doesn’t appear in the FROM list.
    • You shouldn’t write ON xxx AND ON yyy. Just write ON xxx AND yyy.

    Other points to consider:

    • Are you sure that you meant FULL OUTER JOIN and not INNER JOIN?
    • Why do you add the distinct? If a person owns two animals with the same name do you really want to return only one row?
    • Where do the values input1, ..., input4 come from?
    • I think table0 should be renamed to person, table5 to animal, and table1 to person_animal to make it easier to understand the purpose of each table.

    My best guess as to what you meant is this:

    SELECT table0.person_name, table5.animal_name 
    FROM table1 
    JOIN table0 ON table1.person_id = table0.person_id
    JOIN table5 ON table1.animal_id = table5.animal_id
    WHERE table1.aa = input1 
      AND table1.bb = input2 
      AND table1.cc = input3 
      AND table1.dd = input4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are developing an application which consists of: a source code base given to
I've got three tables which all join into one table. Here is the code:
Given a base class with the following interface: public class Base { public virtual
In other words, given a base class shape and a derived class rectangle :
Given the sample code: class Base { public: bool pub; protected: bool prot; };
given a Python class hierarchy, say class Base: def method1 def method2 def method3
Given the following statements in VBA: Assume that val = 4 and Option Base
Given this class: class MyModel < ActiveRecord::Base belongs_to :association1 belongs_to :association2, :polymorphic => true
Given the following models: team.rb class Team < ActiveRecord::Base has_many :events, :dependent => :destroy
I have a table companies , which has two columns named name and address

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.