unemployment Posted January 4, 2011 Share Posted January 4, 2011 $compQ = "SELECT companies.companyid, companies.companyname, companies.companylogo, companies.companyoccupation, companies.industry, eQuestions.capitalrequested FROM companies LEFT JOIN eQuestions ON companies.companyid = eQuestions.companyid"; This is not displaying data correctly. I'm assuming eQuestions.capitalrequested is not in the correct spot? Link to comment https://forums.phpfreaks.com/topic/223325-left-join-is-broken/ Share on other sites More sharing options...
BLaZuRE Posted January 4, 2011 Share Posted January 4, 2011 What do you mean it's not displaying data correctly? What's 'correctly' for you? Each row for eQuestions will have a result row with its corresponding company based on its companyid = companies.companyid. Also, any rows from companies not matched will have a result row with empty rows where results from eQuestions would be. What are you trying to do? Link to comment https://forums.phpfreaks.com/topic/223325-left-join-is-broken/#findComment-1154486 Share on other sites More sharing options...
unemployment Posted January 4, 2011 Author Share Posted January 4, 2011 Quote What do you mean it's not displaying data correctly? What's 'correctly' for you? Each row for eQuestions will have a result row with its corresponding company based on its companyid = companies.companyid. Also, any rows from companies not matched will have a result row with empty rows where results from eQuestions would be. What are you trying to do? I'm trying to make the query say only show companies where companyid matches in both companies and equestions. Right now I am receiving all of the companies in my table before my actual company id. My actual company id is being shown last. I only want it to display data when the companyid's match in both tables. Link to comment https://forums.phpfreaks.com/topic/223325-left-join-is-broken/#findComment-1154488 Share on other sites More sharing options...
BLaZuRE Posted January 4, 2011 Share Posted January 4, 2011 Raw, unchecked code: SELECT companies.companyid, companies.companyname, companies.companylogo, companies.companyoccupation, companies.industry, eQuestions.capitalrequested FROM companies, eQuestions WHERE companies.companyid = eQuestions.companyid; No Left Join needed. You want Left Join when you require everything from the left table and also want what's matched on the right. Link to comment https://forums.phpfreaks.com/topic/223325-left-join-is-broken/#findComment-1154491 Share on other sites More sharing options...
unemployment Posted January 4, 2011 Author Share Posted January 4, 2011 Quote Raw, unchecked code: SELECT companies.companyid, companies.companyname, companies.companylogo, companies.companyoccupation, companies.industry, eQuestions.capitalrequested FROM companies, eQuestions WHERE companies.companyid = eQuestions.companyid; No Left Join needed. You want Left Join when you require everything from the left table and also want what's matched on the right. That worked... Thank you. Link to comment https://forums.phpfreaks.com/topic/223325-left-join-is-broken/#findComment-1154495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.