Reputation: 13
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?
Thanks,
Upvotes: 0
Views: 56
Reputation: 40318
select * from Users u , Permissions p where u.permission_id = p.p_id;
Visual Representation of SQL Joins
Upvotes: 3
Reputation: 4748
You can perform a SELECT
query that will return all of this data that you want.
Try this:
SELECT *
FROM users u
INNER JOIN permissions p ON p.p_id = u.permission_id
Upvotes: 3