Cupara
Well-known member
I am attempting to LEFT JOIN 3 tables into the main but if I do it this way:
Then my expert levels work, display title and all but no user or node information is pulled, but if I do this:
I get the forum titles, user information but no level information.
I am probably doing the join wrong so if someone with better experience with joins could take a look and provide a suggestion for a fix I would appreciate it.
PHP:
$db = XenForo_Application::get('db');
return $db->fetchAll('
SELECT info.posts, info.likes, info.user_id, info.forum_id, user.user_id, user.username, node.title, node.node_id, levels.mye_post_amount, levels.mye_like_amount, levels.mye_title
FROM myexpert_levels AS levels
LEFT JOIN myexpert_info AS info ON (info.posts = levels.mye_post_amount) AND (info.likes = levels.mye_like_amount)
LEFT JOIN xf_user AS user ON (user.user_id = info.user_id)
LEFT JOIN xf_node AS node ON (node.node_id = info.forum_id)
');
Then my expert levels work, display title and all but no user or node information is pulled, but if I do this:
PHP:
$db = XenForo_Application::get('db');
return $db->fetchAll('
SELECT info.posts, info.likes, info.user_id, info.forum_id, user.user_id, user.username, node.title, node.node_id, levels.mye_post_amount, levels.mye_like_amount, levels.mye_title
FROM myexpert_info AS info
LEFT JOIN xf_user AS user ON (user.user_id = info.user_id)
LEFT JOIN xf_node AS node ON (node.node_id = info.forum_id)
LEFT JOIN myexpert_levels AS levels ON (info.posts = levels.mye_post_amount) AND (info.likes = levels.mye_like_amount)
');
I get the forum titles, user information but no level information.
I am probably doing the join wrong so if someone with better experience with joins could take a look and provide a suggestion for a fix I would appreciate it.