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)"; 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'. 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. Link to comment https://forums.phpfreaks.com/topic/227070-sum-broke-query/#findComment-1173592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.