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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:25:59+00:00 2026-06-06T14:25:59+00:00

I have three tables in oracle db as newitems, itemdetails, ticketitems table. Some dummy

  • 0

I have three tables in oracle db as newitems, itemdetails, ticketitems table.
Some dummy data as follow:

TICKETITEMS:

id    ticketid     itemid    quantity

1     100          9999      2
2     100          9998      5
3     100          2222      3

ITEMDETAILS:

id    description    col_sumthing   extra_col
9999  Marlboro       val_sumthing   123_op
9998  Cigar Black    val_sumthing   456_pqwe

NEWITEMS:

id    description    col_sumthing
2222  100Pipes       val_different

Initially i had to fetch data only from itemdetails + ticketitems which was very easy using simple joins. Query for which was:

SELECT "TI".*, "I"."ID" AS "ITEMID", "I"."DESCRIPTION", "I"."col_sumthing" 
  FROM "TICKETITEMS" "TI"
 INNER JOIN "ITEMDETAILS" "I" ON TI.ITEMID = I.ID
 WHERE (TI.TICKET = '100')

Something like that.

Now newitem table introduced which may also have some items present in ticketitems table.

So i want a result like:

Final Result:
id    description    itemid    quantity   col_sumthing    extra_col
1     Marlboro       9999      2          val_sumthing    123_op
2     Cigar Black    9998      5          val_sumthing    456_pqwe
3     100Pipes       2222      3          val_different   

The problem I m facing is, it should only check in NEWITEMS when no details found in itemdetails. Any other work around is also welcomed.

  • 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-06T14:26:00+00:00Added an answer on June 6, 2026 at 2:26 pm

    You could use two OUTER joins:

    SELECT ti.*, 
           nvl(i.id, n.id) itemid, 
           nvl(i.description, n.description) description, 
           nvl(i.col_sumthing, n.col_sumthing) col_sumthing 
      FROM ticketitems ti
      LEFT JOIN itemdetails i ON ti.itemid = i.id
      LEFT JOIN newsitems n ON ti.itemid = n.id
     WHERE ti.ticket = '100'
    

    This will work as long as both detail tables have ID as a primary key. Use COALESCE if you have more than two detail tables.

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

Sidebar

Related Questions

I have three tables of data: table: cars [10,000 rows] table: planes [2,000 rows]
I have three tables. I have to retrieve the data using Linq statement. My
I have three tables Author, Book and AuthorBook. AuthorBook table only contains two foreign
I have some Oracle tables that represent a parent-child relationship. They look something like
I have some tables in Oracle enviroment which I have found could benefit from
I have two very large enterprise tables in an Oracle 10g database. One table
I have the following tables in Oracle 11g: Table A SITE_ID SITE_NAME VECTOR .........MANY
I'm working on Oracle and Perl. I have three fields in a table (A,
I have a common database joining situation involving three tables. One table, A, is
I have an Oracle table with data that looks like this: ID BATCH STATUS

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.