# SQL compare database

**URL:** <https://community.unix.com/t/sql-compare-database/343811>\
**Category:** Shell Programming and Scripting\
**Created:** [June 19, 2014, 11:40pm UTC](https://community.unix.com/t/sql-compare-database/343811 "2014-06-19T23:40:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![siya1](https://community.unix.com/letter_avatar/siya1/32/6_449c533f586939b6e5f246632a46421f.png) [@siya1](https://community.unix.com/u/siya1)\
**Post date:** [June 19, 2014, 11:40pm UTC](https://community.unix.com/t/sql-compare-database/343811/1 "2014-06-19T23:40:02Z")

</div>

Hi ,

I have 2 databases which has same table names and I need to list entries of a particular table in database1 not existing in the same tablename of database2.

eg : I have db1 having table name orders

```nohighlight
 ad_d | code | start | end | amountscore | id | amount_class |
+--------+--------+----------+----------+----------+--------------+--------------+
| 1 | ww | 935002 | 935100 | 245 | Ath | boeing |
| 1 | e | 4406486 | 4406628 | 575 | Lth | boeing |
| 1 | r | 30313484 | 30313585 | 348 | SSU | boeing |
| 18 | f | 44787276 | 44787468 | 1338 | SSU | boeing |
| 1 | g | 44787462 | 44787856 | 2775 | Ath | target |
| 1 | m | 44787855 | 44787944 | 747 | Ath | boeing |
| 1 | n | 53636773 | 53636856 | 549 | SSU | target |
| 1 | m | 53888147 | 53888282 | 695 | SSU | genev |
| 1 | q | 53888312 | 53888394 | 399 | Ath | boeing |
| 1 | c | 53888396 | 53888428 | 251 | Ath | geneva |
| 1 | f | 53888461 | 53888589 | 583 | gth | geneva    

```

I only want to list those entries from table name orders in database 1 not present in same table name (orders) in database 2 .  
The only condition is I only want to list those entries whose amount\_class ='boeing'

Therefore I am interested in those entries having amount\_class = "boeing" in table amount\_class of DB1 not present in same table name in DB2

I tried

```nohighlight
select * 
from (
      select *
      from DB1.orders
      except
      select *
      from DB2.orders
     ) as amountclass
Where amount_class ='Boeing';

```

Am I missing something?

---

<div class="post-metadata">

**Author:** ![Chubler\_XL](https://community.unix.com/user_avatar/community.unix.com/chubler_xl/32/2077_2.png) [@Chubler\_XL](https://community.unix.com/u/Chubler_XL)\
**Post date:** [June 22, 2014, 10:15pm UTC](https://community.unix.com/t/sql-compare-database/343811/2 "2014-06-22T22:15:58Z")

</div>

You may find [this thread](http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=23054) useful.
