Home » SQL & PL/SQL » SQL & PL/SQL » Join two tables (Oracle 10 g)
Join two tables [message #291132] Thu, 03 January 2008 02:04 Go to next message
sssnbj
Messages: 3
Registered: January 2008
Junior Member
hi,

this might sound very basic, but am sure there must be an easy way to do it!
am trying to join two tables A,B on a key K , the problem is that there are value of K in A that are not in B
and accordingly the join will return the smaller set common in borth tables, while what I really want is to have the common set in addition to the other records with some default values in case of mismach.


what I did was a lengthy SQL which works fine:
I join A,B normally to get the commen records from A,B and then I UNION the result with a A MINUS B (adding default values in the select clause for columns supposingly comming from B) this is an SQL statement with 3 sub queries (too much for a simple job, isnt it)

Please let me know of any better way to do this job,
thanks

[Updated on: Thu, 03 January 2008 02:06]

Report message to a moderator

Re: Join two tables [message #291133 is a reply to message #291132] Thu, 03 January 2008 02:08 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Use outer join

Regards
Michel
Re: Join two tables [message #291134 is a reply to message #291132] Thu, 03 January 2008 02:09 Go to previous messageGo to next message
varu123
Messages: 754
Registered: October 2007
Senior Member
joining two tables
Re: Join two tables [message #291135 is a reply to message #291133] Thu, 03 January 2008 02:10 Go to previous message
sssnbj
Messages: 3
Registered: January 2008
Junior Member
I knew such goodies exist Smile
Thanks
Previous Topic: where to create external table
Next Topic: CLOB data INSERT and READ?
Goto Forum:
  


Current Time: Fri Feb 14 10:03:09 CST 2025