Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Query help .. wrong join??

Author  Topic 

jpotucek
Constraint Violating Yak Guru

273 Posts

Posted - 2009-04-09 : 13:41:27
MS SQL Server 2000 SP4 -

Ths query brings back 473 rows
[CODE]
use towerdb
select * from tower.nbdocdeletedrecords where presentdate>= '04/07/2009' and presentdate<= '04/08/2009' order by towid[/CODE]

This query brings back 474 rows (the same 473 as above and one extra)
[CODE]use modify_title
Select distinct towid,update_date,update_action from dbo.mat_audit_nbdoc where Update_Date >= '04/07/2009' and Update_Date < '04/08/2009'
and update_action = 'DELETE' order by towid[/CODE]

I'd LIKE this query to show me only the one row that is different but I think my join might be wrong or I'm missing SOMETHING :


[CODE]select a.towid,a.update_date,a.update_action,b.towid,b.presentdate

from modify_title.dbo.mat_audit_nbdoc as a left outer join towerdb.tower.nbdocdeletedrecords as b

on (a.towid = b.towid)
where
a.Update_Date >= '04/07/2009'
and a.Update_Date < '04/08/2009'

and b.presentdate>= '04/07/2009'
and b.presentdate<= '04/08/2009'
order by a.towid[/CODE]

I need it to only return the one row that is different.. can anyone help me out here?

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-04-09 : 14:12:11
I think you need this,

and b.towid is null
Go to Top of Page
   

- Advertisement -