SQL update syntax and Examples
The routine database tutorial is an ever-changing data storage. SQL is used to modify The data that has been updated in The database and delete commands. The update statement can update one or more
SQL update syntax and instances
The daily use of the database tutorial is a constantly changing data store. In SQL is used to modify data that has been updated and deleted in the database commands.the UPDATE statement can update
Tags: select Set sel mail warnings and end highlight conditionUPDATE ' Warningsendmail ' as Alias_1 INNER JOIN (SELECT * from ' Warningsendmail ' WHERE flag=1 and topic_id like "%2267%") A S alias_2 SET alias_1.topic_id = REPLACE (alias_1.topic_id, ' |2267 ', ') WHERE alias_1.id = alias_2.id
update Warningsendmail set topic_id= REPLACE (topic_id, ' |2267 ', ') where ID in (SELECT ID from warningsendmail where flag=1 and T opic_id like "%2267%");
SQL update syntax and instances
The daily use of the database tutorial is a constantly changing data store. In SQL is used to modify data that has been updated and deleted in the database commands.the UPDATE statement can update
MySQL Union table update and deletion syntax introduction, mysql Union table syntax
Preface
I believe that when you use mysql in daily use, you may need to update two tables at the same time. I will use two SQL statements in the same transaction to
. Otherwise, it is changed to the name of the table, output modified data to a temporary table)
Update pnset pn. id = case when t. id> ''then t. id else pn. id endoutput deleted. id into temporary table from table name pn with (nolock) join # temp t
13. query, insert, delete, sum, average, and maximum
Select * from tableinsert into new_table (id, name) values (1, 'zhang san') delete from table where range select sum (field1) as sumvalue from table1sel
SQL Update multi-table joint Update method, sqlupdate joint Update
Sometimes we need to update the data in multiple tables at the same time, then we need to use the following method:
(1) sqlite multi-Table update Method
Copy codeT
Related Articles:
MySQL "on duplicate key update" Syntax
Insert into .. on duplicate key to update multiple rows
Http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#insert
MySQL "on duplicate key update" Syntax
If the on dupl
The most common update syntax is:
Update Set
Set If my updated value is taken out of a SELECT statement and there are many columns, It is very troublesome to use this syntax.First, you need to select and place it on a temporary variable. There are manySecond, assign values to the variables.It is very troublesome to add multiple columns. Can I insert the resu
UPDATE c=c+1;After execution, the value of C becomes 4 (the second is repeated with the first one, and C is +1 on the original value).Copy the code code as follows:INSERT into TABLE (a,c) VALUES (1,3), (1,7) on DUPLICATE KEY UPDATE c=values (c);After execution, the value of C changes to 7 (the second is repeated with the first one, and C is the value of the duplicate 7 directly).Note: On DUPLICATE KEY
(1,3), (1,7) on DUPLICATE KEY UPDATE c=c+1;After execution, the value of C becomes 4 (the second is repeated with the first one, and C is +1 on the original value). Copy CodeThe code is as follows:INSERT into TABLE (a,c) VALUES (1,3), (1,7) on DUPLICATE KEY UPDATE c=values (c);After execution, the value of C changes to 7 (the second is repeated with the first one, and C is the value of the duplicate 7 dire
, the value of C changes to 4 (the second one repeats with the first, and C is +1 on the original value).
Copy Code code as follows:
INSERT into TABLE (a,c) VALUES (1,3), (1,7) on DUPLICATE KEY UPDATE c=values (c);
After execution, the value of C changes to 7 (the second one repeats with the first, and C takes a duplicate value of 7 directly).
Note: On DUPLICATE KEY update is only a
repeats with the first, and C is +1 on the original value).
Copy Code code as follows:
INSERT into TABLE (a,c) VALUES (1,3), (1,7) on DUPLICATE KEY UPDATE c=values (c);
After execution, the value of C changes to 7 (the second one repeats with the first, and C takes a duplicate value of 7 directly).Note: On DUPLICATE KEY update is only a unique syntax for My
, c) VALUES (1, 3), (1, 7) on duplicate key update c = VALUES (c );After the execution, the value of c will change to 7 (the second repeat with the first repeat, and c will take the repeat value 7 directly ).Note: on duplicate key update is only a special MySQL syntax, not a standard SQL
value of c is changed to 4 (the second repeat with the first one, and c is on the original value + 1 ).Copy the Code as follows:
Insert into table (a, c) VALUES (1, 3), (1, 7) on duplicate key update c = VALUES (c );
After the execution, the value of c will change to 7 (the second repeat with the first repeat, and c will take the repeat value 7 directly ).Note: on duplicate key update is only a special MyS
The update operation is one of the most common operations to use a database. The following describes the update Syntax of data that is not inserted repeatedly in MYSQL for your reference. It is helpful for you to learn how to update data.
If you specify the on duplicate key update
Update
An update expression that updates the data values of the fields in the table, where you can set a specific conditional expression, and records that match the conditional expressions are updated.
The syntax is as follows:
UPDATE table
New value for SET field
WHERE condition Expression
You need an
c is on the original value + 1 ).Copy codeThe Code is as follows:Insert into table (a, c) VALUES (1, 3), (1, 7) on duplicate key update c = VALUES (c );After the execution, the value of c will change to 7 (the second repeat with the first repeat, and c will take the repeat value 7 directly ).Note: on duplicate key update is only a special MySQL syntax, not a sta
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.