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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:30:48+00:00 2026-05-20T13:30:48+00:00

I’m looking for the best way to display all rows from two tables while

  • 0

I’m looking for the best way to display all rows from two tables while joining first by one field (dwg) then where applicable a 2nd join on part.

Table1 data consists of schematics(dwg) along with a list of parts required to build the item depicted in the drawing. Table2 consists of data about the actual parts ordered to build the schematic. Some parts in table2 are a combination of parts in table1 (ex: foo and bar in table1 were ordered as foobar in table2).

I can display all rows in both tables with UNION ALL, but this doesn’t join on both the dwg and part fields. I looked at FULL OUTER JOIN also, but I haven’t figured out how to join first by dwg, then by part. Here is an example of the data.

table1                   table2   
dwg        part    qty       order   dwg      part    qty  
-----      -----   -----    -----    -----   -----   -----  
123        foo     1        ord1     123     foobar  1  
123        bar     1        ord1     123     bracket 2  
123        widget  2        ord2     123     screw   4  
123        bracket 4        ord2     123     nut     4  
456        foo     1        ord2     123     widget  2  
                            ord2     123     bracket 2  
                            ord3     456     foo     1  

Desired output:
The goal is to create a view that provides visibility to all parts in table1 and the associated orders in table2 (including those parts that appear in one but not the other table) so that I can see all the drawing parts in table1 and the associated records in table2 along with records in table2 where the part wasn’t in table1.

part_request_order_report  
dwg      part      qty   order   part    qty  
-----    -----     ----- ------  -----   -----  
123      foo       1  
123      bar       1  
123      widget    2     ord2    widget  2  
123      bracket   4     ord1    bracket 2  
123      bracket   4     ord2    bracket 2  
123                      ord1    foobar  1  
123                      ord1    screw   4  
123                      ord1    nut     4  
456      foo       1     ord3    foo     1  

Is this possible? Or am I better off iterating through the data to build the report table? Thanks in advance.

  • 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-20T13:30:48+00:00Added an answer on May 20, 2026 at 1:30 pm

    This should give you the right result :

    select
        coalesce(table1.dwg,table2.dwg),
        table1.part,
        table1.qty,
        table2.order,
        table2.part,
        table2.qty,
    from table1
    full outer join table2 on 
        table1.dwg = table2.dwg and
        table1.part = table2.part
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm making a simple page using Google Maps API 3. My first. One marker
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.