Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm new to mySQL relastionships and I'm wondering if you can help me out.

This is what I want to do:

Users Table

user_id
user_name
pass_word
permission_id

Permissions Table

p_id
permission_name
permission_type

I want to create a relationship between p_id (permissions table) & permission_id (user table) so when I query the user table it also brings through the corresponding permission name & type?

Is this possible or am I getting it all wrong?

Should I just use joins?

share|improve this question

1 Answer 1

SELECT  u.user_id, 
        u.user_name, 
        u.pass_word,
        p.permission_name,
        p.permission_type
FROM Users u
  INNER JOIN Permissions p
ON u.permission_id  = p.p_id;

Max.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.