Home » SQL & PL/SQL » SQL & PL/SQL » Selecting one of the Union Clause (Oracle 10g, Win XP)
Selecting one of the Union Clause [message #315653] Tue, 22 April 2008 05:54 Go to next message
freakabhi
Messages: 74
Registered: November 2007
Location: mumbai
Member
Hi all,

I have following query :

select Id, Data_address, data_details
from Possible_test

union

select Id, Data_address, data_details
from imPossible_test


here I have id as key field in both the tables, now my problem is in some case same ID may appear in both the Possibe_test abd impossible_test tables, so in that case query should suppress row coming from impossible_test.

I dont know how to do it?
please can anybody help.

from
Freakabhi
Re: Selecting one of the Union Clause [message #315655 is a reply to message #315653] Tue, 22 April 2008 05:56 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
select Id, Data_address, data_details
from Possible_test

union

select Id, Data_address, data_details
from imPossible_test
where id not in (select ID from possible_Test)
Re: Selecting one of the Union Clause [message #315661 is a reply to message #315653] Tue, 22 April 2008 06:08 Go to previous message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Assuming Id is the primary key, you must use UNION ALL instead of UNION.

Regards
Michel
Previous Topic: If any Provision to Know the Updated records data.
Next Topic: storing the value into a variable in a stored procedure
Goto Forum:
  


Current Time: Sun Dec 11 04:29:39 CST 2016

Total time taken to generate the page: 0.15327 seconds