Mowgli
Mowgli

Reputation: 3512

SQL not include field ID which includes following

I am reading data from 3 tables

ID is common between all 3 tables.

This works

select 

        T1.ID,
        T2.CAUSE_NO,
        T2.CAUSE_TYPE,
        T3.START_NO,
        T3.START_TYPE,
        T1.Comments
from    Table1 T1,
        Table2 T2,
        Table3 T3

where   T2.ID = T3.ID 
    and T1.ID = T2.ID 
    AND T2.CAUSE_NO NOT IN (64,8,43,63,65)

I also need to add condition where I don't want to Include ID where CAUSE_NO = 13 and START_NO = 83.

below is sample table. green is what I want end result and red rows should not be included. enter image description here Can someone help add this condition.

Upvotes: 0

Views: 397

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270573

I think you want this where clause:

where   T2.ID = T3.ID 
    and T1.ID = T2.ID 
    AND T2.CAUSE_NO NOT IN (64,8,43,63,65)
    AND not (CAUSE_NO = 13 and START_NO = 83)

You should also learn to use ANSI standard join syntax.

Upvotes: 1

Related Questions