Computing.Net > Forums > Database > SQL compact multiple row update

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

SQL compact multiple row update

Reply to Message Icon

Name: the123
Date: March 25, 2007 at 09:15:52 Pacific
OS: XP
CPU/Ram: 512
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: March 27, 2007 at 11:33:09 Pacific
Reply:

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


0

Response Number 2
Name: the123
Date: March 28, 2007 at 07:02:08 Pacific
Reply:

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.


0

Response Number 3
Name: Michael J (by mjdamato)
Date: March 28, 2007 at 16:43:27 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: SQL compact multiple row update

oracle 9i sql question www.computing.net/answers/dbase/oracle-9i-sql-question/649.html

Reading a part of a string in SQL www.computing.net/answers/dbase/reading-a-part-of-a-string-in-sql/711.html

Many to Many query www.computing.net/answers/dbase/many-to-many-query/368.html