[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

RE: Select query in sql 2000

RickSean

3/28/2007 12:21:00 AM

The following query return duplicate records:
select TableA.Col1, TableA.Col2, TableB.Cola, TableC.Colb1
from TableA
left outer join TableB on TableA.Col1=TableB.Col1
and left outer join TableC on TableA.Col1=TableC.Col1

"Krishnakumar S" wrote:

> Use OUTER JOINs between the table. Always post DDL and sample data so that we
> can understand the problem easly.
> --
> Krishnakumar S
>
> What lies behind you and what lies before you is nothing compared to what
> lies within you
>
>
> "RickSean" wrote:
>
> > I have a table TableA (Col1, Col2, Col3) which contains 5000 records. Col1 is
> > the key field.
> > Another table TableB (Col1, Cola, Colb) contains 300 records, Col1 is the
> > key field.
> > Another table TableC (Col1, Cola1, Colb1) contains 100 records, Col1 is the
> > key field.
> >
> > I want to return all 5000 records from TableA in the following format:
> > Output:
> > Col1 Col2 Col3 Cola Colb1
> >
> > If TableA or TableB does not contain a value for Col1 then Cola and Colb1
> > should output NULL in the result set.
> >
> > If my question can be answered without a ddl; it would be highly
> > appreciated. Otherwise, i will try to post a ddl.