Jump to content

Help please - UPDATE... SET col_name = ... IF something


Tom Read

Recommended Posts

Hi.

 

I'm doing a project at college, making a snooker league website.

 

I have a form that has Team, Player and High Break. When submitted, they're stored in a database. This also updates the 'Player Stats' table.

 

What I want to do is for the High Break column in the Player Stats table to update if the high break entered is greater than the value in the table already.

 

For instance, if it says: Tom Read | 43, and in the form I type 36, I want it to remain as 43. If however a break for Tom Read added is 70, I want it to replace the 43. I can't quite get it right though!

 

I want to say something along the lines of:

 

mysql_query ("UPDATE player_table SET High_Break = $high_break IF $high_break > col_value WHERE Player_Name = '$player_name'");

 

Help would be appreciated, thanks :)

Not certain this is what you're looking for, but according to the information you provided . . .

 

"UPDATE player_table SET High_Break = $high_break WHERE Player_Name = '$player_name' AND $high_break > High_Break"

Archived

This topic is now archived and is closed to further replies.

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