I am trying to join 3 tables together but I keep getting 'unknown table 'calls' in field list. I know the table 'calls' exists
This works...
$sql = "SELECT * FROM calls WHERE id = '$diary_id'";
but this doesn't...
$sql = "SELECT * FROM (SELECT calls.id AS calls_id, calls.assigned_user_id AS assigned_user) calls
RIGHT JOIN accounts on accounts.parent_id = accounts.id
LEFT JOIN users on assigned_user = user.id
WHERE calls_id = '$diary_id'";
I am trying to use aliases because the tables I am trying to join have the same field names (an inherited database I have to use).
Any help will be greatly appreciated