unemployment Posted July 18, 2011 Share Posted July 18, 2011 I need to get all of this info for all of my users, but right now if I remove the where clause I still only get 1 row returned. What am I doing wrong? $sql = "SELECT `users`.`id`, `users`.`firstname`, `users`.`lastname`, `users`.`username`, `users`.`email`, `users`.`gender`, `users`.`accounttype`, `users`.`personalweb`, `users`.`guestviews`, `users`.`iviews`, `users`.`eviews`, `users`.`credentials`, `users`.`specialties`, `users`.`country`, `users`.`city`, `users`.`state`, `users`.`phonenumber`, `users`.`dateofbirth` AS `dob`, `users`.`mail_status`, `investor_info`.`investor_type`, DATE_FORMAT(`users`.`dateofbirth`,'%D') AS `dayofbirth`, DATE_FORMAT(`users`.`dateofbirth`,'%c') AS `monthofbirth`, DATE_FORMAT(`users`.`dateofbirth`,'%Y') AS `yearofbirth`, DATE_FORMAT(`users`.`dateofbirth`,'%D \of %M %Y') AS `dateofbirth`, DATE_FORMAT(`users`.`signupdate`,'%D %M %Y') AS `signupdate`, SUM(`investor_info`.`capital_available`) AS `totalavailable`, `companytype`, `capital` FROM `users` LEFT JOIN `investor_info` ON `users`.`id` = `investor_info`.`uid` LEFT OUTER JOIN employees ON users.id = employees.userid LEFT OUTER JOIN ( SELECT companies.companyid, companies.companytype AS `companytype`, SUM(companies.capital) AS `capital` FROM `companies` GROUP BY companies.companytype) SumCompanies ON employees.companyid = SumCompanies.companyid WHERE `users`.`username` = '${username}'"; Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 18, 2011 Share Posted July 18, 2011 might depend on how you are displaying the query. Are you using a loop to do this? Might help if you posted the code as well Quote Link to comment Share on other sites More sharing options...
unemployment Posted July 18, 2011 Author Share Posted July 18, 2011 might depend on how you are displaying the query. Are you using a loop to do this? Might help if you posted the code as well The problem is not in the code, but rather in the query. Phpmyadmin does not display multiple rows when I run the query. I would ultimately end up using a foreach loop for the output, but I need to get the query correct first. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted July 18, 2011 Share Posted July 18, 2011 so a mysql_num_rows shows 1? If that is the case then I will look at your query further Quote Link to comment Share on other sites More sharing options...
unemployment Posted July 18, 2011 Author Share Posted July 18, 2011 so a mysql_num_rows shows 1? If that is the case then I will look at your query further Yeah, I fixed it by adding in a group by id to the end. 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.