SQL: Join value from another table
I have 1 table called accounts and another one called level_points
Basically the idea is to determine what is the minimum amount of points
you need to be X level.
Account Structure
id, name.. etc. points
Level_Points Structure
level, points
Values in here such as
(1, 5) (2, 10) (3, 15)
I'm able to calculate the level using this query
"SELECT level FROM level_points WHERE points <= (SELECT points FROM
accounts WHERE id = 'x') ORDER BY level DESC LIMIT 1"
My problem is that now i'm trying to join the tables to get something like
this (For every user in the accounts table)
Result:
For user 1: id, name etc... points, level For user 2: id, name etc...
points, level For user 3: id, name etc... points, level
I'm not exactly sure how to do this using joins and I can't seem to find
an answer here that helps me here. Thanks.
No comments:
Post a Comment