• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Optional join of tables

 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,
I have three tables INVOICE, WEB_ORDER, ORDER.
INVOICE and WEB_ORDER can be linked using the column "customer_id".
WEB_ORDER and ORDER can be linked using the column "order_id"
ORDER table contains the column "trading_partner" and INVOICE has the other column of interest "invoice_id".
WEB_ORDER is not guaranteed to contain the rows with the same "customer_id"
as in INVOICE table.
I like to get the "invoice_id" (always) and trading_partner (if exists)
by joining the 3 tables. I tried the SQL below:

I know my invoice table has 118 rows. When I execute the above select,
I get only 110 rows. How do I get all 118 rows and still query for
trading_partner if exists?
Thanks a lot.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sai. How are you?
This might not work, but what if you remove the unique keyword. How many records do you get then?
Which database are you using? because I thought the keyword is DISTINCT and not UNIQUE. Maybe both work.
Mark
 
Get out of my mind! Look! A tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic