Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all,
I am using a sql compact database to update my records.
I know the syntax to update one row and colums but is there a way/syntax to use the update keyword to update multiple rows and colums using one update keyword or another way to do it using sql compact?
using (UPDATE table SET C2 = 'value', C3=value WHERE C1= 'value';)
tried:
UPDATE table SET C2 = 'value', C3=value WHERE C1= 'value';
UPDATE table SET C2 = 'value', C3=value WHERE C1= 'value';)does not work also tried with begin and commit any help?
Thanks

A couple options depending on the data type:
UPDATE table SET C2 = 'value', C3=value WHERE C1= 'value1' OR C1= 'value2' OR C1= 'value3'
UPDATE table SET C2 = 'value', C3=value WHERE C1 IN ('value1','value2','value3')
Michael J

thanks for you reply.
I can see how the columns updates would work.
but not the row by row. Because each row has different values.Care to explain a little. The data type is text and numbers.

Well, by using "generic" values and names it makes it confusing. Let's assume I have a table called users and in that table I have the following columns: name, gender, shirtSize
Ok, let's suppose that the shirtSize field had been entered with the correct size for each user, but now we found out we will not have enough Medium (M) or Large (L) shirts. So a decision is made to change the shirt size to Extra Large (XL) for all the men who had Medium or Large shirts.
This could be done with the following statement:
UPDATE users
SET shirtSize = 'XL'
WHERE gender = 'M'
AND (shirtSize='M' or shirtSize='L')
Michael J

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |