mysql - Sql join 3 tables -


i have struggle produce sql. relationship part of application. have 3 tables : users('id'), relationship('user_id', 'member_id'), relationship_block('user_id', 'blocked_member_id')

i members belonging user user_id not blocked.

records of first table 'users' in 'relationships' table not in 'relationship_blocked' table. first 2 can join, want remove blocked.

thanx.

edit: found info here: http://explainextended.com/2010/05/27/left-join-is-null-vs-not-in-vs-not-exists-nullable-columns/

select *     users u         inner join relationship r             on u.user_id = r.user_id         left join relationship_block rb             on r.user_id = rb.user_id                 , r.member_id = rb.blocked_member_id     rb.user_id null 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -