1. Environment: MySQL-5.0.41-win32 Windows XP Professional 2. Establish a test environment: DROP TABLE IF EXISTS t_test; CREATE TABLE t_test ( bs bigint(20) NOT NULL auto_increment, username varchar(20) NOT NULL, password varchar(20) default NULL, remark varchar(200) default NULL, PRIMARY KEY (bs) )ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=gbk; INSERT INTO t_test VALUES (1,'lavasoft','123456',NULL); INSERT INTO t_test VALUES (2,'hello',NULL,NULL); INSERT INTO t_test VALUES (3,'haha',zz,tt); 3. Testing 1. Set a field In the table t_test, set the password of the second record (bs=2) to '***'. update t_test t set t.password = '***' where t.bs = 2; 2. Set multiple fields In the table t_test, set the password of the first record (bs is 1) to '*' and remark to '*'. update t_test t set t.password = '*', t.remark = '*' where t.bs = 1; 3. Set null value In the table t_test, set the password and remark of the third record (bs is 3) to null and null respectively. update t_test t set t.password = null, t.remark = null where t.bs = 3; Conclusion This is written according to the standard syntax. In different database systems, there are more ways to write update, but the standard syntax is supported. In order to illustrate the situation, the above three examples update one row each time. In practice, the number of updated rows can be controlled through where statement constraints. You may also be interested in:
|
<<: An example of how Vue implements four-level navigation and verification code
>>: How to use Nginx to proxy multiple application sites in Docker
Table of contents premise TypeScript vs JavaScrip...
Table of contents 1. Component Communication 1. P...
Table of contents I. Overview 2. pt-archiver main...
The file server is one of the most commonly used ...
Table of contents 1. What is Pinia? 2. Pinia is e...
Obvious HTML, hidden "public script" Th...
Table of contents Overview Example Why is it need...
Table of contents 1. Use the uuid function to gen...
Table of contents 1. The elephant that can’t fit ...
Preface Index Condition Pushdown (ICP) is a new f...
Table of contents Preface 1. Custom focus command...
Preface In the case of primary key conflict or un...
Focus images are a way of presenting content that ...
This article shares a small example of adding and...
Syntax format: row_number() over(partition by gro...