kingfisher kingfisher - 1 year ago 39
SQL Question

full join & where condition

select *
from Table1
full join Table2 on Table2.Common = Table1.Common


In the above query, I want to add this
where
condition:

where (Table1.StatusId > 100 or Table1.StatusId is not null)


StatusId
is of datatype
numeric(18, 2)
.

The problem is when I use the
where
condition, rows in
Table2
which don't have any connecting data in
Table1
are not showing up anymore.

Is there any other way to add this
where
condition?

Answer Source

Try to put it on a Subquery.

SELECT  *
FROM    ( SELECT    *
          FROM      Table1
          WHERE     ( Table1.StatusId > 100
                      OR Table1.StatusId IS NOT NULL
                    )
        ) T
        FULL JOIN Table2 ON Table2.Common = t.Common
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download