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开发者_JAVA百科 clue how to implement this?
SELECT * FROM Table1 AS t1
INNER JOIN Table2 AS t2
ON t2.id = t1.id
WHERE t2.Approve != 'N'
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.
精彩评论