Petty_Crim
03-27-2009, 05:10 AM
I am trying to get fields from two tables based upon if their ids are the same.
I have a table called user with the following fields:
userid
username
And one called player_stats with the following fields
player_id
correct
gotr_wins
season_id
My query is as follows:
$get_leaders=mysql_query("SELECT * FROM user, player_stats WHERE userid=player_id AND season_id='".$_POST['season_id']."' ORDER BY correct DESC, gotr_wins DESC, username ASC LIMIT ".mysql_real_escape_string($_POST['start']).",".mysql_real_escape_string($_POST['end'])."") or die ("Error getting leaders ".mysql_error());
This returns 0 results despite there being fields in both tables that match. If I take out "userid=player_id" it works but gives me several outputs for the same player. I need it so that it only gets ones where there is a match.
I have had a look at several online examples and they are the same as mine, it doesn't make sense why its not working.
I have a table called user with the following fields:
userid
username
And one called player_stats with the following fields
player_id
correct
gotr_wins
season_id
My query is as follows:
$get_leaders=mysql_query("SELECT * FROM user, player_stats WHERE userid=player_id AND season_id='".$_POST['season_id']."' ORDER BY correct DESC, gotr_wins DESC, username ASC LIMIT ".mysql_real_escape_string($_POST['start']).",".mysql_real_escape_string($_POST['end'])."") or die ("Error getting leaders ".mysql_error());
This returns 0 results despite there being fields in both tables that match. If I take out "userid=player_id" it works but gives me several outputs for the same player. I need it so that it only gets ones where there is a match.
I have had a look at several online examples and they are the same as mine, it doesn't make sense why its not working.