Mysql – New to theSQL Relationships

MySQL

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?

Best Answer

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.