"Peter Yeoh" wrote:
> My bad, should've been
>
> SELECT a.* FROM TableA a INNER JOIN TableB b ON a.SystemID = b.SystemID
> INNER JOIN TableC on b.SystemID = c.SystemID AND (c.ImpSystemID = 0 OR
> c.IsCompleted = 0)
>
>
> Peter Yeoh
>
http://www.yohz.com > Need smaller SQL2K backups? Try MiniSQLBackup
>
>
> "Peter Yeoh" <nospam@nospam.com> wrote in message
> news:enL7s2rTEHA.3872@TK2MSFTNGP10.phx.gbl...
> > SELECT a.* FROM TableA a INNER JOIN TableB b ON a.SystemID = b.SystemID
> > INNER JOIN TableC on b.SystemID = c.SystemID AND c.ImpSystemID <> 1 AND
> > c.IsCompleted <> 1
> >
> > Peter Yeoh
> >
http://www.yohz.com > > Need smaller backups? Try MiniSQLBackup
> >
> >
> > "Ramnadh" <Ramnadh@discussions.microsoft.com> wrote in message
> > news:F535B695-C794-4BF8-8DD8-200DFDAA5904@microsoft.com...
> > > HI,
> > > Thanx for ur reply
> > >
> > > There is another thing i doesn't remind to tell you, i am giving it with
> > example data
> > >
> > > Table A :
> > > EmpId SystemId
> > > 1 11
> > > 1 4
> > > 1 10
> > > 1 5
> > > 1 2
> > > 2 11
> > > 2 4
> > > 3 4
> > > 3 11
> > >
> > > Table B :
> > > SystemId
> > > 11
> > > 4
> > >
> > > Table C :
> > > EmpId SystemId ImpSystemId IsCompleted
> > > 1 11 1 1
> > > 1 4 1 0
> > > 1 10 0 0
> > > 2 4 1 1
> > > 2 11 1 0
> > > 3 11 1 1
> > >
> > >
> > > The result Set should be :
> > >
> > > EmpId SystemId
> > > 1 4
> > > 2 11
> > > 3 4
> > >
> > > Means the systems in the Table B should contain compulsarily in the
> Table
> > A and the EmpId & SystemId having ImpSystemId = 1 and Iscompleted = 1
> should
> > ignore.
> > >
> > >
> > > "oj" wrote:
> > >
> > > > select *
> > > > from A join B on A.SystemId=B.SystemId
> > > > left join C on A.EmpId=C.EmpId and A.SystemId=C.SystemId
> > > > where C.ImpSystemId != 1 and C.IsCompleted != 1
> > > >
> > > >
> > > > "Ramnadh" <Ramnadh@discussions.microsoft.com> wrote in message
> > > > news:DD7EC684-5297-42CC-BD9B-4273D324FCAC@microsoft.com...
> > > > > Hi,
> > > > > I have three tables with the Structures.
> > > > >
> > > > > Table A : (EmpId , SystemId)
> > > > > Table B : (SystemId)
> > > > > Table C : (EmpId, SystemId, ImpSystemId, IsCompleted)
> > > > >
> > > > > Table A is the Master table it is having all the rows.
> > > > > Table B refers the Master table A which SystemId refers
> A.SystemId
> > > > > Table C refers the Master table A which all the rows may not
> exists
> > as in
> > > > the Master Table.
> > > > >
> > > > > The query is that we have to get the rows which the A.SystemId IN
> > (B.SystemId)
> > > > > and Have to ignore the rows with values in the Table C having
> > ImpSystemId = 1
> > > > and IsCompleted = 1 and have to get the remaining rows.
> > > >
> > > >
> > > >
> >
> >
>
>