Loading ...
Sorry, an error occurred while loading the content.

Re: [SQLQueriesNoCode] Selecting a count based on different columns

Expand Messages
  • Sergio Coelho
    HI! AFAIK Mysql doesn t support nested queries (only the latest version, but, it is still in pre-release mode) Also, i ve found a few bugs with the GROUP BY
    Message 1 of 2 , Jul 18, 2003

      AFAIK Mysql doesn't support nested queries (only the latest version, but, it
      is still in pre-release mode)
      Also, i've found a few "bugs" with the GROUP BY function of MySQL, it
      doesn't always work...

      Try some newsgroup at Mysql.com .... they're really great guys and help a

      (sorry if i don't help much...)


      Sergio Coelho Charrua
      Flesk lda
      WebDevelopment Team
      @ : scoelho@...
      url : www.flesk.com

      ----- Original Message -----
      From: "thomas_pickert" <Thomas@...>
      To: <SQLQueriesNoCode@yahoogroups.com>
      Sent: Tuesday, July 15, 2003 4:23 PM
      Subject: [SQLQueriesNoCode] Selecting a count based on different columns

      > Hi!
      > I'm new to this group, so please be gentle. :-)
      > I'm maintaining a game which is using a MySQL database. This game is
      > based on players who have (several) characters which are living in
      > different locations.
      > I now want to find out which players have more than 2 characters in
      > one location. I could do that using a script, of course, but I have
      > the vague feeling that it should be possible to do it in a SQL query.
      > The table 'chars' has int columns 'player' (which is the associated
      > player for the character), 'location' (the character's location)
      > and 'id' (which is the character's unique id).
      > My first approach was:
      > SELECT player FROM chars GROUP BY location, player HAVING count(*) >
      > 2;
      > But that one only counts the characters for each location, always
      > resulting in a count > 2. That means, that this query simply lists
      > all players.
      > I somehow need to tell count that it should only count the characters
      > for a particular player per location. Is something like a nested
      > aggregate function possible? I haven't found out anything about that
      > yet.
      > I would appreciate any help. Also the hint, that is actually NOT
      > possible to do it in a query is welcome. And don't refrain from
      > telling me that this is the wrong forum either.
      > Regards, Thomas.
      > To unsubscribe from this group, send an email to:
      > SQLQueriesNoCode-unsubscribe@yahoogroups.com
      > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    Your message has been successfully submitted and would be delivered to recipients shortly.