tags:

views:

40

answers:

2

Hi

I have 2 tables

Table 1

ID  Status
1   D
2   F
3   D

Table 2


SID ID  Approve
1   1   N
2   1   Y
3   1   Y
4   2   Y

I need a query to joins 2 tables on ID and finds records that don not have N in their Approve column. Does anyone have any clue how to implement this?

+4  A: 
SELECT * FROM Table1 AS t1 
INNER JOIN Table2 AS t2 
ON t2.id = t1.id 
WHERE t2.Approve != 'N' 
Jage
The Query result is repeating the records in Table 1 as many child rows it have. The problem is I need only 1 output for a record. If I add Group by it groups in {Records with Y and Records with N} So it gives one record but shows one with N too. Any Idea?
Krishma
How do you know which child you need?
Jage
A: 
SELECT DISTINCT t1.id,t1.status,t2.approve FROM Table1 AS t1 
INNER JOIN Table2 AS t2 
ON t2.id = t1.id 
WHERE t2.Approve != 'N'

you can't have the t2.sid in the select clause though as it will void the DISTINCT criteria.

Dave.Sol