Jump to content

Struggling to get my query right, can you help?


Recommended Posts

Hi Freaks

 

I'm trying to create a query that will show the results of a poker game.

I have the following tables & Fields in my mysql database:

Player                                Position                                        Results                                      Venue

-MembershipNo                    -Position                                      -ResultID                              - VenueID

-FirstName                          -Points                                        -VenueID                              - VenueName

-NickName                                                                              -MembershipNo                     

-LastName                                                                              -Date

-Address                                                                                  -Position

-Town           

-Postcode         

-Email

 

I have several tables showing total points per player, number of times played, average number of players at each venue, but I can't seem to get this one right.

 

The plan is to have a dropdown list where you can select a date & Venue Name (some venues play on the same date so both checks are needed) then on the selected date I need just the players names, finishing position and points by order of position for that particular venue.

 

So far all I've managed to get is the same players name repeated for ever venue?!

I know this shouldn't be that hard, but I'm stuck on it!

 

Any suggestions would be greatly received!

 

Cheers

 

PHP_Idiot

Your 'Position' table seems extraneous to me.

 

<?php
$date = mysql_real_escape_string( $_POST['date'] );
$venue_id = mysql_real_escape_string( $_POST['venue_id'] );
$select = "
SELECT
  p.`FirstName`, p.`NickName`, p.`LastName`,
  po.`Position`, po.`Points`
FROM `Player` p
INNER JOIN `Results` r ON p.`MembershipNo`=r.`MembershipNo`
INNER JOIN `Venue` v ON v.`VenueID`=r.`VenueID`
INNER JOIN `Position` po ON po.`Position`=r.`Position`
WHERE
    r.`Date`={$date}
    AND v.`VenueID`={$venue_id}
ORDER BY po.`Position`
";
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.