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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:57:20+00:00 2026-06-08T18:57:20+00:00

I am facing problem with sql query when I try to join this tree

  • 0

I am facing problem with sql query when I try to join this tree table and get the data. I am using Oracle database.

Personal

id_no   name
-------------    
0001    John
0002    Peter
0003    Mike

position
id_no  name
-------------
0001  programmer
0002  Engineer
0003  Clerk

extra_skill
employee_id    skill
--------------------------
0001         Visual Studio 2008
0003         Crystal Report

Requirement:
Display details of employees:

Example:

Employee No : 0001
Employee Name : John
Employee Position : Programmer
Employee Skill : Visual Studio 2008

My sql statement is

SELECT a.id_no, a.name, b.name, c.skill
  FROM personal a, POSITION b, extra_skill c
 WHERE a.id_no = b.id_no
   AND b.id_no = c.employee_id
   AND c.employee_id = "USER INPUT";

The problem is when

SELECT a.id_no, a.name, b.name, c.skill
  FROM personal a, POSITION b, extra_skill c
 WHERE a.id_no = b.id_no
   AND b.id_no = c.employee_id
   AND c.employee_id = "0002";

This query give me NULL because in the table extra_skill does not have 0002.

I want it possible to get data even in the third table no value.

Expected result:
  Employee No : 0002
  Employee Name : Peter
  Employee Position : Engineer
  Employee Skill : 

How can I implement such a query?

Your attentions and helps are much appreciated.
Thank you, Siti..:)

  • 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-08T18:57:22+00:00Added an answer on June 8, 2026 at 6:57 pm

    The way to do this is with outer joins. I have used the ANSI joining syntax (introduced in Oracle 9i) for this example, because it is clearer and also Oracle now recommend using it.

    SELECT a.id_no, a.name, b.name as position, c.skill 
      FROM personal a INNER JOIN position b
            on (a.id_no = b.id_no )
          LEFT OUTER JOIN extra_skill c 
           on ( a.id_no = c.employee_id )
    WHERE a.id_no = '0002'; 
    

    Note that I have changed the filter condition to select on PERSONAL.ID. If you attempt to use c.employee_id = '0002' (as you do in your question) you will get no rows returned.


    You could include EXTRA_SKILLS.EMPLOYEE_ID in the join condition rather than the WHERE clause.

    SELECT a.id_no, a.name, b.name as position, c.skill  
    FROM personal a INNER JOIN position b 
        on (a.id_no = b.id_no ) 
      LEFT OUTER JOIN extra_skill c  
       on ( a.id_no = c.employee_id  
            and c.employee_id = '0002'); 
    

    Generally including filters in the join section is not considered good practice, because it can effect the result set in ways we’re not expecting. In your case it will return every row in PERSONAL and POSITION and no values from EXTRA_SKILL. This is probably not what you want to happen. Here is a SQL Fiddle to prove it.

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

Sidebar

Related Questions

I am facing an unusual problem in Oracle SQL Developer. When I try to
I'm trying to query an Excel spreadsheet using SQL. The problem I'm facing is
Facing a problem, it seems my data stored in SQL Server does not stored
I am facing problem to get variable from query string. I have used htaccess
Facing problem for generating SQL Server Query In the Following query dynamic conditions are
I am facing here a problem with a SQL statement, which fetches the data
I am facing a problem for writing an sql query which should be easy
iam facing problem in passing array to view. this is my controller code.. function
I am facing problem with UIPanGestureRecognizer. suppose i am adding 10 button dynamicaly using
I have created a sample query in sql server to parse data from xml

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.