SQL select statement from 2 tables

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2010-05-05T19:47:22Z Indexed on 2010/05/05 19:58 UTC
Read the original article Hit count: 271

Filed under:
|
|
|

Hi, I have a small sql question.

I have 2 tables

Members and Managers

Members has: memberID, Name, Address Managers has: memberID, EditRights, DeleteRights

EditRights and DeleteRights are of type bit.

Mangers have a relationship with Members, because they are members themselves.

I want to select all members id's, name and adress and for the members that are managers show if they have editrights and/or deleterights.

SO:

Exmaple data

Members:

ID, Name, Address
1, tom, 2 flat
2, dan, 3 flat
3, ben, 4 flat
4, bob, 6 flat
5, sam, 9 flat

Managers:

ID, Editrights, deleterights 
2, 0, 1
4, 1, 1
5, 0, 0

I would like to display a select like this:

1, tom, 2 flat, no rights
2, dan, 3 flat, Delete
3, ben, 4 flat, no rights
4, bob, 6 flat, Edit&Delete
5, sam, 9 flat, no rights

Any help would be great

© Stack Overflow or respective owner

Related posts about sql

Related posts about select