aspose file tools
The moose likes Oracle/OAS and the fly likes Optional join of tables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Reply Bookmark "Optional join of tables" Watch "Optional join of tables" New topic
Author

Optional join of tables

Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
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.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17225
    
    1

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Optional join of tables
 
Similar Threads
Hibernate .hbm.xml - Referential Integrity constraint
autoincrement invoice
Simple SQL joining 2 tables - 2 many rows being returned
Stumped on a SQL Statement
Hibernate Foreign Keys