Felhasználó tábla:
+----+----------+------+
| id | username | rank |
+----+----------+------+
| 1 | teszt | 1 |
| 2 | teszt2 | 3 |
+----+----------+------+
Rangok tábla:
+----+------+----------------+
| id | rank | description |
+----+------+----------------+
| 1 | 1 | Moderátor |
| 2 | 2 | Adminisztrátor |
| 3 | 3 | Tulaj |
+----+------+----------------+
Lekérdezés:
SELECT
t1.*,
t2.description
FROM
users AS t1
LEFT JOIN
ranks AS t2
ON
t1.rank = t2.rank
WHERE
t1.username = \'teszt\'
LIMIT 1;
Eredmény:
+----+----------+------+-------------+
| id | username | rank | description |
+----+----------+------+-------------+
| 1 | teszt | 1 | Moderátor |
+----+----------+------+-------------+