2013-01-08 41 views
0

編寫查詢我有兩個表需要在兩個表

Member (member_id,...) 
friend-requests(member_id, friend_id) 

我需要member_id說19來從成員表中的所有記錄,哪些不是在列friend_id

回答

1
select * from member join friend-requests 
on member.member_id=friend_requests.member_id 
where 
member.member_id=19 
and 
not exists (select f.member_id from friend-requests f where f.mmeber_id = member.member_id) 
0
Select m.* from Member as m 
where member_id=19 and 
member_id not in (select friend_id from friend_requests where member_id=19)