unemployment Posted February 8, 2011 Share Posted February 8, 2011 I broke my query when I added in SUM. Any idea why? $sql = "(SELECT `users`.`firstname`, `users`.`lastname`, `users`.`accounttype`, SUM(`partners`.`approved`) FROM `partners` INNER JOIN `users`"; $sql .= " ON `partners`.`user_id` = `users`.`id` WHERE `partners`.`friend_id` = ${uid} AND `approved` = 1)"; $sql .= " UNION ALL "; $sql .= "(SELECT `users`.`firstname`, `users`.`lastname`, `users`.`accounttype`, SUM(`partners`.`approved`) FROM `partners` INNER JOIN `users`"; $sql .= " ON `partners`.`friend_id` = `users`.`id` WHERE `partners`.`user_id` = ${uid} AND `approved` = 1)"; Quote Link to comment https://forums.phpfreaks.com/topic/227070-sum-broke-query/ Share on other sites More sharing options...
Maq Posted February 8, 2011 Share Posted February 8, 2011 Define 'broke'. Quote Link to comment https://forums.phpfreaks.com/topic/227070-sum-broke-query/#findComment-1171485 Share on other sites More sharing options...
fenway Posted February 13, 2011 Share Posted February 13, 2011 As usual, echo the actual sql statement, and the accompanying error. Quote Link to comment https://forums.phpfreaks.com/topic/227070-sum-broke-query/#findComment-1173592 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.