Вопрос

First time using an Android database for my application. I've researched update statements and I keep seeing examples using a single row ID to update but what if I use a composite key? The only way to find a unique row is with a season number and team name and my database. So I need to create a statement like..

UPDATE table_name
SET wins=5, losses=3
WHERE Team_Name='Something' AND Season='1;

Is this possible? There could be multiple rows(around 8), I would need to do this at a time. And would probably use variables for team name and what not. Thanks for any help.

Это было полезно?

Решение

Yes it is possible. If your season is a string then you would use:

UPDATE table_name 
SET wins = 5, losses = 3 
WHERE Team_Name = 'Something' 
AND Season = '1'

However, if your season is a number then you would use:

UPDATE table_name 
SET wins = 5, losses = 3 
WHERE Team_Name = 'Something' 
AND Season = 1
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top