You are here: OUTER JOIN not working? « MsSQL Server « IT news, forums, messages
OUTER JOIN not working?

Posted by kamin on 07/07/06 16:46

I have this query

select
created_date,
tyg_aging_due_dates.object_type,
tyg_aging_due_dates.due_date
from
#tyg_aging_service_metrics
right join
tyg_aging_due_dates
on tyg_aging_due_dates.due_date =
#tyg_aging_service_metrics.due_date
and tyg_aging_due_dates.object_type =
#tyg_aging_service_metrics.object_type
order by PS, tyg_aging_due_dates.due_date

Basically the table tyg_aging_due_dates have this for data
object_type due_date
----------- --------
report 1/1/2005
report 1/1/2006
report 1/1/2007
image 2/1/2006
image 2/4/2006

The temporary table retuns something similar
created_date object_type due_date
------------ ----------- --------
6/1/2006 report 1/1/2005
6/10/2006 image 2/4/2006


So basically I want to join the two tables and for the due date's that
are missing from my temporary table, I want to display NULL (thus the
right join).

So my query would return
created_date object_type due_date
------------ ----------- --------
6/1/2006 report 1/1/2005
NULL report 1/1/2006
NULL report 1/1/2007
NULL image 2/1/2006
6/10/2006 image 2/4/2006

The date fields are of smalldatetime. Object type is a varchar(15).

When I run my query though, I get only 2 rows back. No matter if I
switch the right join to a left, full, inner, whatever. I still only
get 2 rows back. Is this a known issue?

I am running Microsoft SQL Server 2000 - 8.00.2039 (Intel X86) May
3 2005 23:18:38 Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 1)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация