im making a WF where i get to insert soccer results, however the team winning should get 3, the losing team 0, if its a draw both should get 0.
i have a DB called voetbaldb, with a table called teams, where the scores of the teams should be updated, with 3 columns called ID which is primary key, teamname and teamrank which is unique.
however, i add results with my windows from into my 'results' table, but i want to add points to the 'team' table.
this is my code, however i just cant get it work, i cant find away to give the winnning team the points it deserves:
how to insert data into table based on conditions on the other table
int value;
if (int.TryParse(txt_box_home_score.Text > txt_box_away_score.Text, out value))
{
UPDATE teams SET teamrank = (SELECT ISNULL(MAX(teamrank), 0) + 3 FROM teams)
}
if else (int.TryParse(txt_box_home_score.Text < txt_box_away_score.Text, out value))
{
UPDATE teams SET teamrank = (SELECT ISNULL(MAX(teamrank), 0) + 3 FROM teams)
}
else (int.TryParse(txt_box_home_score.Text == txt_box_away_score.Text, out value))
{
UPDATE teams SET teamrank = (SELECT ISNULL(MAX(teamrank), 0) +1 FROM teams)
}
Aucun commentaire:
Enregistrer un commentaire