Home » SQL & PL/SQL » SQL & PL/SQL » minus operator
minus operator [message #21735] Tue, 27 August 2002 00:50 Go to next message
Raj
Messages: 411
Registered: November 1998
Senior Member
hi,
if i use minus operator i want the duplicate records also to be displayed.
for example
in table t1 (id number)
id
1
2
1
in table t2 (id number)
id
3
if i give the following query
select id from t1
minus
select id from t2
output :
1
2
3
i want the output to be displayed as
1
1
2
3
thanks and regards,
raj
Re: minus operator [message #21736 is a reply to message #21735] Tue, 27 August 2002 01:19 Go to previous messageGo to next message
Raj
Messages: 411
Registered: November 1998
Senior Member
hi,
if i use minus operator i want the duplicate records also to be displayed.
for example
in table t1 (id number)
id
1
2
1
in table t2 (id number)
id
3
if i give the following query
select id from t1
minus
select id from t2
output :
1
2

i want the output to be displayed as
1
1
2
3
thanks and regards,
raj
Re: minus operator [message #21739 is a reply to message #21735] Tue, 27 August 2002 05:50 Go to previous messageGo to next message
Victoria
Messages: 152
Registered: July 2002
Senior Member
Hi ,
You can use union all for this.
Thanks and Regards
Victoria
Re: minus operator [message #21744 is a reply to message #21735] Tue, 27 August 2002 08:22 Go to previous messageGo to next message
UmsSund
Messages: 1
Registered: August 2002
Junior Member
Raj

Union all will do the trick as Victoria suggested....

select id from t1
union all
select id from t2

Thanks
-UmaSund
Re: minus operator [message #21750 is a reply to message #21735] Tue, 27 August 2002 20:41 Go to previous message
Raj
Messages: 411
Registered: November 1998
Senior Member
hi,
thanks for the reply.but if i use union all it w'll select all the records from both the tables.i want all the records from first table which is not in second table.so, i have to use minus operator.but, it is selecting the distinct records.

bye,
raj
Previous Topic: chr(10) function to read 4 lines
Next Topic: RETURNING CLAUSE
Goto Forum:
  


Current Time: Tue Jul 22 04:44:22 CDT 2025