E-mail Print PDF

1
2
3
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value

Note Note:

Пример SQL

There is a table "Persons":

P_IdLastNameFirstNameAddressCity
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
4 Nilsen Johan Bakken 2 Stavanger
5 Tjessem Jakob

For this we use this query:

1
2
3
 UPDATE Persons
 SET Address=, City=
 WHERE LastName='Tjessem' AND FirstName='Jakob'

Query Result:

P_IdLastNameFirstNameAddressCity
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
4 Nilsen Johan Bakken 2 Stavanger
5 Tjessem Jakob Sandnes

Предупреждение SQL

1
2
UPDATE Persons
SET Address=, City=

P_IdLastNameFirstNameAddressCity
1 Hansen Ola Sandnes
2 Svendson Tove Sandnes
3 Pettersen Kari Sandnes
4 Nilsen Johan Sandnes
5 Tjessem Jakob Sandnes

Comments

 
-3 #1 Шелест Константин 2010-10-28 19:11 (So, we want to update columns "Tjessem, Jakob" in the table "Persons") - is said correctly, I think it would be correct to say - "to update the tuple value of 5 P_Id attribute table Persons". Quote
 
 
+10 #2 Шелест Константин 2010-10-28 21:38 So a little easier:

Persons
SET Address = 'Santa path 67', City = 'Sandnes'
WHERE P_Id = 5;
Quote
 
 
+5 #3 Azat 2010-10-28 22:17 Tell me, but what if you need to drive the word SET (a) and even the value of one of the columns.

For example, from your examples to be so
table_name
SET column1 = 'column3 my word', column1 = 'my words column4 another word'
WHERE some_column=some_value
How to?

Thank you very much.
Quote
 
 
+5 #4 Шелест Константин 2010-10-29 13:55 As far as I know, in a single cell can be only one value, or write everything by hand (meaning column3, 2, and let your word). Quote
 
 
+1 #5 Azat 2010-10-29 16:12
(Meaning column3, dopustim 2 and your word).


Prescribe please him Constantine. (And still value column3 not numbers but words) Thank you.

I tried using the options for a bunch of words and a column value signs +, (comma) - but fails.

I want one word and its meaning for all rows column3 column1.
Quote
 
 
+7 #6 Шелест Константин 2010-10-29 18:02 (I want one word and its meaning for all rows column3 column1.) I'm just learning, I do not know how to do it.
But as I said teachers in the same cell may be one condition. Do you want to Azat vphnut there two conditions. But if you get it, please write how it looks. )))
Quote
 
 
+6 #7 Юрий Дяченко 2010-11-07 07:44
Tell me, but what if you need to drive the word SET (a) and even the value of one of the columns.

table_name
SET column1 = CONCAT (column3, 'my word')
WHERE some_column=some_value
Quote
 
 
+4 #8 Azat 2010-11-09 22:04 Many thanks to Yuri. Quote
 
 
-1 #9 HellDRG 2011-01-30 01:21 Tell me, please, and how to write, I have a table
login not
log1 1111
log2 2222

C using SQL to specify the query:
nameTable SET login = 'log3', not = '11111 'WHERE (that I need to write on, so the value has changed in the second row, with the proviso that we do not know the contents of the table)
Thank you in advance)
Quote
 
 
-1 #10 Monarh 2011-02-25 12:35 I completely agree c Whisperwind Constantine
Sentence: Quote:
- Sounds ill!
In my opinion is better to write like this:
"So we want to update columns Address, and City line LastName = 'Tjessem' and FirstName = 'Jakob'"
Quote
 

Authorization

Nice Ajax Poll

Which one of my extensions is the best?

Statistics

Translate

русскийitalianoDeutschEnglishLATVIANукраїнськаfrançaispolski
1

Advertisement