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
What is element-ui element-ui is a desktop compon...
Table of contents 1. React Hooks vs. Pure Functio...
Preface Through my previous Tomcat series of arti...
Use HSSFWorkbook in Apache.POI to export to Excel...
Achieve results The code is as follows html <t...
Introduction to Load Balancing Before introducing...
Take zabbix's own WEB interface as an example...
Logo optimization: 1.The logo image should be as ...
Context definition and purpose Context provides a...
Preface I have installed MySQL 5.6 before. Three ...
1. Preparation Install Tomcat on Linux system, us...
On CentOS 7, when we map the host port to the con...
Table of contents text 1. Prepare the machine 2. ...
Around version 0.6, privileged was introduced to ...
This article shares the specific code for JavaScr...