I have tried searching for many examples but my is a little more complicated as I have many columns. Here is a simplified version:
users
+--------+----------+
| userid | username |
+--------+----------+
| 1 | Tom |
+--------+----------+
| 2 | Dick |
+--------+----------+
| 3 | Harry |
+--------+----------+
type
+--------+----------+
| typeid | typename |
+--------+----------+
| 1 | Desktop |
+--------+----------+
| 2 | Laptop |
+--------+----------+
computers
+------+--------+-------------------+------------------+--------------------+--------------------+
| pcid | typeid | bought_by_user_id | assigned_user_id | created_by_user_id | updated_by_user_id |
+------+--------+-------------------+------------------+--------------------+--------------------+
| 1 | 2 | 1 | 3 | 1 | 3 |
+------+--------+-------------------+------------------+--------------------+--------------------+
| 2 | 1 | 2 | 2 | 2 | 2 |
+------+--------+-------------------+------------------+--------------------+--------------------+
| 3 | 1 | 3 | 2 | 3 | 1 |
+------+--------+-------------------+------------------+--------------------+--------------------+
the result I would like to achieve is
+------+---------+----------------+---------------+-----------------+-----------------+
| pcid | type | bought_by_user | assigned_user | created_by_user | updated_by_user |
+------+---------+----------------+---------------+-----------------+-----------------+
| 1 | Desktop | Tom | Harry | Tom | Harry |
+------+---------+----------------+---------------+-----------------+-----------------+
| 2 | Laptop | Dick | Dick | Dick | Dick |
+------+---------+----------------+---------------+-----------------+-----------------+
| 3 | Desktop | Harry | Dick | Harry | Tom |
+------+---------+----------------+---------------+-----------------+-----------------+
I've tried using multiple ONs like so:
SELECT * FROM computers
LEFT JOIN types ON computers.typeid = types.typeid
LEFT JOIN users
ON users.userid = computers.bought_by_user_id
ON users.userid = computers.assigned_user_id
ON users.userid = computers.created_by_user_id
ON users.userid = computers.updated_by_user_id
but that didn't work... Halp?