Jump to content

fenway

Staff Alumni
  • Posts

    16,168
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by fenway

  1. Yeah, you can't do that.... SUM() can't take a result set.
  2. which mysql version?
  3. Wait a second... there's an "OR" in the where clause!!!
  4. Sorry, I still have no idea what the problem is.
  5. Ha! Funny... sorry about that: SELECT scorer, sum(goals) as total_goals, Sum(IF(team_id =1 and league="league",goals,0)) AS firstleague, Sum(IF(team_id =1 and league="friendly",goals,0)) AS firstfriendly, Sum(IF(team_id =2 and league="friendly",goals,0)) AS fathoms, Sum(IF(team_id =3 and league="friendly",goals,0)) AS badgers from `tbl_scorers` group by scorer order by total_goals desc;
  6. fenway

    sql error ?

    Start again -- new file, new script -- run a simple query, make sure it works.
  7. I don't understand... does the equivalent select query pull all of the towns?
  8. Huh?
  9. Where the SET NAMES from php?
  10. Give me a few INSERT statements, and I'll get to work...
  11. The "@" suppresses errors....
  12. Bizarre... and if you actually specify a new IDs directly it's fine?
  13. fenway

    sql error ?

    Maybe *all* isn't the best idea -- isolate the query first.
  14. What's "it" in this case... there's a php side to this issue as well.
  15. Since you're supressing errors, we're not going to get very far.
  16. What's the error now?
  17. If I think I get what you're saying, it's that the non-aggregated columns are producing garbage... correct/
  18. You were on the right track... just remove the trailing comma after badgers before FROM.
  19. Huh?
  20. The PHP Help forum is pefect for stuff like this.. do you want me to move this thread?
  21. You could, though, with ALTER TABLE, say for a table that isn't being updated anymore (e.g. ARCHIVE).
  22. Well, you simply sort your results set with the first ID... and then if the next ID isn't different, add a column, otherwise, add a new row, etc.
  23. Why not simply: SELECT scorer, Sum(IF(team_id =1 and league="league",1,0) AS firstleague, Sum(IF(team_id =1 and league="friendly",1,0) AS firstfriendly, Sum(IF(team_id =2 and league="friendly",1,0) AS fathoms, Sum(IF(team_id =3 and league="friendly",1,0) AS badgers, FROM tbl_scorers group by scorer
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.