Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare two SELECT statement using PL/SQL Developer

Suppose I have two SELECTquery on same table and I need to compare them column by column.

Query 1:

select * from mytable t1 where  t1.code = '100'

returns:

id           name
1            A
2            B

Query 2:

select * from mytable t2 where  t2.code = '999'

returns:

id           name
1            A
2            C

For my case both query returns same number of rows.

Desired result

id           name_t1     name_t2
2            B           C

How can I found the data difference between them using PL/SQL developer (better using tools to avoid query)?

My PL/SQL Developer Version 8.0.3.1510


1 Answers

you can use MINUS

select * from mytable t1 where  t1.code = '100'

MINUS 
select * from mytable t2 where  t2.code = '999';

MINUS gives you the rows that are found in the first query and not in the second query by removing from the results all the rows that are found only in the second query

like image 189
Ramki Avatar answered Sep 01 '26 18:09

Ramki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!