List:General Discussion« Previous MessageNext Message »
From:Jerry Preeper Date:April 12 1999 7:29pm
Subject:update table problem
View as plain text  
Hello,

I'm having a bit of a problem updating a table from a perl script.
Basically, I'm trying to calculate standings from games where scores are
kept in another table.  I have queries which calculate the wins losses,
etc... and they work fine.  I know they work because I inserted a print
statement right before my update query and I see all of the calculated
fields.  

Following the print statement is my query to update the standings table
below.  No matter what I seem to do, I can not get it to insert the data
into the table.  I have the perl script running with -w and get no error
messages - just the output from the print statement.

    print "$team_name $total_wins - $total_losses - $total_ties
($total_games)<br>\n";

    $sql_query = "update $standings_table set ";
    $sql_query .= "total_games = $total_games ";
    $sql_query .= ", total_wins = $total_wins ";
    $sql_query .= ", total_losses = $total_losses ";
    $sql_query .= ", total_ties = $total_ties ";
    $sql_query .= "where team='$team_name'";


I have tried entering data directly from the command line and the following
worked fine

mysql> update standings_table set
total_games=8,total_wins=5,total_losses=3,total_ties=0 where team =
'LaJollaPinto';



The $standings_table exists and there are records in it for each team in
the league.  A show columns from the standings table results in 
+--------------+----------+------+-----+---------+-------+
| Field        | Type     | Null | Key | Default | Extra |
+--------------+----------+------+-----+---------+-------+
| team         | char(64) |      | PRI |         |       |
| total_games  | int(4)   | YES  |     | NULL    |       |
| total_wins   | int(4)   | YES  |     | NULL    |       |
| total_losses | int(4)   | YES  |     | NULL    |       |
| total_ties   | int(4)   | YES  |     | NULL    |       |
+--------------+----------+------+-----+---------+-------+

I have also tried using replace with the following code, but that didn't
work either.

$sql_query = "replace into $standings_table ";
$sql_query .= "where team = '$team_name' ";
$sql_query .= "(total_games,total_wins,total_ties,total_losses) ";
$sql_query .= "values ($total_games,$total_wins,$total_ties,$total_losses)";

Does anyone have any ideas what I might be missing?

Jerry P



Thread
update table problemJerry Preeper12 Apr
Re: update table problemJerry Preeper13 Apr