我正在尝试将“users”表中的“userTypeId”与“userRoles”表中的相应“id”相匹配,以便我可以在“userRoles”中回显“roleName”。
以下是表格:
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
我试过这个查询,每当我检查它时,它都会回显“错误”
$roleQuery = "SELECT id, roleName, userTypeId FROM userRoles JOIN users ON id=userTypeId";
$roleResult = mysqli_query($dbconnect, $roleQuery);
if(!$roleResult){
echo 'WRONG';
} else {
echo 'RIGHT';
}