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? Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
unemployment Posted January 4, 2011 Author 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? 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
unemployment Posted January 4, 2011 Author 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. That worked... Thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.