SQLTeam.com | Weblogs | Forums

Join query


#1

Hi

I have two queries, #1 is the main query, #2 is stored all exceptions.

#1
select * from table1 a
inner join table2 b
on a.id= b.id
where 1 =1

#2
select exception
from item a
where FKey_int = 55

it returned the exception results such as below
and item like '35%' or like '36%')
and (type = 1)
and warehouse <> 'TTT'

I need to combine two queries 1 and 2 into one below, but it returned 2 independ results. Can some one please help to put them into one query?

select * from table1 a
inner join table2 b
on a.id= b.id
where 1 =1
(select exception
from item a
where FKey_int = 55
)

thanks


#2

Please post DDL and inserts with consumable data representing a subset of your data in these tables.