| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
SQL compact multiple row update
|
Original Message
|
Name: the123
Date: March 25, 2007 at 09:15:52 Pacific
Subject: SQL compact multiple row updateOS: XPCPU/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
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Michael J (by mjdamato)
Date: March 27, 2007 at 11:33:09 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: the123
Date: March 28, 2007 at 07:02:08 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Michael J (by mjdamato)
Date: March 28, 2007 at 16:43:27 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|

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