i’m trying to match a “userTypeId” in the “users” table to its corresponding “id” in the “userRoles” table so that I can echo the “roleName”, also in “userRoles”.
Here are the tables:
userRoles
---------------------
id roleName
1 superuser
2 admin
3 editor
4 author
5 contributor
6 subscriber
users
---------------------
id userName userTypeId
1 heyjohnmurray 1
2 admin 2
I tried this query and whenever i check it, it echoes out “WRONG”
$roleQuery = "SELECT id, roleName, userTypeId FROM userRoles JOIN users ON id=userTypeId";
$roleResult = mysqli_query($dbconnect, $roleQuery);
if(!$roleResult){
echo 'WRONG';
} else {
echo 'RIGHT';
}
add an
ALIASon the tables,or better use the format (ANSI SQL-92)