Jump to content

schone

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by schone

  1. Hi All! Here is some initial info: Table reports_interventions has: - id - date - player_id - qu_id - value [b]What I'm trying to do is:[/b] Select all the player_id's who have the the same qu_id three times or more. [i]For example[/i] date = 2006-05-20 player_id = 5 qu_id = 3 value = 4 date = 2006-05-21 player_id = 5 qu_id = 3 value = 3 date = 2006-05-22 player_id = 5 qu_id = 3 value = 7 [b]What I have currently is:[/b] [code] SELECT COUNT( qu_id ) , player_id FROM reports_interventions GROUP BY player_id, qu_id HAVING COUNT( qu_id ) >3 [/code] The problem is that it selects all qu_ids and counts them. What I want it to do is [b]select all qu_ids[/b] which are [b]the same[/b] which [b]occur 3 times or more[/b] for a [b]certain player_id.[/b] Please Help!!! Thanks to All! :)
  2. Hi all! I have the following table: [b]recovery_interventions[/b] - id - player_id - date - qu_id - value Here is my code: [code] <?php     $result = mysql_query("SELECT player_id, DATE_FORMAT(date, '%d/%m/%y') AS new_date, qu_id, value                            FROM reports_interventions                            ORDER BY player_id, date DESC");          while($row = mysql_fetch_array($result, MYSQL_ASSOC))         {             $player_id = $row['player_id'];             echo $player_id;                          $result_num = mysql_query("SELECT player_id                                FROM reports_interventions                                WHERE player_id = $player_id");             $num_rows = mysql_num_rows($result_num);                          for($i=0; $i < $num_rows; $i++)    {                          echo "<br>";             echo $row['new_date'];             echo "<br>";                             echo $row['qu_id'];             echo "<br>";             echo $row['value'];             echo "<p>";                          }         } ?> [/code] Now [b]MY PROBLEM[/b] :) What Im trying to do is display a player_id and then its date, qu_id and value. There is many dates, qu_ids and values associated with individual player_id's. For example I would like my output to look like this: player_id : 4 date : 10/10/06 qu_id : 4 value : 2 date : 10/10/06 qu_id : 6 value : 3 date : 10/10/06 qu_id : 9 value : 1 [b]At the moment its displaying:[/b] player_id : 4 date : 10/10/06 qu_id : 4 value : 2 date : 10/10/06 qu_id : 4 value : 2 player_id : 4 date : 10/10/06 qu_id : 6 value : 3 date : 10/10/06 qu_id : 6 value : 3 player_id : 4 date : 10/10/06 qu_id : 9 value : 1 date : 10/10/06 qu_id : 9 value : 1 I have wrecked my brain and the mysql.net and php.net manuals but get no where! Please help!
  3. [!--quoteo(post=372954:date=May 10 2006, 10:59 AM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ May 10 2006, 10:59 AM) [snapback]372954[/snapback][/div][div class=\'quotemain\'][!--quotec--] Try the following (UNTESTED): [code]SELECT players_answers.player_id, players_answers.date, players.player_id, players.givenname,  players.surname FROM players LEFT JOIN players_answers ON (players_answers.player_id = players.player_id AND date=NOW()) WHERE players_answers.player_id IS NULL[/code] BTW, you shouldn't have the group by in either of these. [/quote] Hi Fenway! The following query displays every player_id. :( I have asked every person I know that knows mySql about this and no one can work it out!
  4. Hi Just a summary about my tables: [b]players_answers[/b] - id (auto_inc) - date - player_id - value [b]players[/b] - id (auto_inc) - player_id - givenname - surname Here is my query: [code] SELECT players_answers.player_id, players_answers.date, players.player_id, players.givenname,  players.surname FROM players_answers INNER JOIN players ON (players_answers.player_id = players.player_id AND date=NOW()) GROUP BY players_answers.player_id [/code] What i'm trying to do is grab all the players names that have an entry on today's date. [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]Which works fine![!--colorc--][/span][!--/colorc--] [b]My problem is[/b] that how would I go about getting all the players name's that don't have an entry on this date. So the exact opposite of this query! I have tried to use date!=NOW(). But the problem is all players in the players_answers have dates ranging back to Janurary, so all players get displayed when I put that clause in. [b]Please someone help![/b] Thank You!
×
×
  • 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.