国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Mysql addition, deletion, modification and query update records

Update record

Update data We have already said. When you need to modify content, modify bank card balances, or modify equipment information, you need to use update and modify statements.

The basic syntax of the modification (also called update) statement is as follows:

CategoryDetailed explanation
Basic syntaxupdate table name set field 1=value 1, field 2=value 2, field n=value n where conditions
Exampleupdate money set balance=balance-500 where userid = 15;
Example descriptionModify the money table and change The balance balance is reduced by 500. The required userid is 15

Suppose we have the following table, the table structure is as follows:

##1王寶強50000.002黃曉明150000000.00##1516

mysql> select * from emp where deptno=15;
+------+----------+----------+
| userid |username| ?balance |
+------+----------+----------+
| 15 ? | ?馬云 ? ?| 15000.00 |
+------+-------+-------------+
1 row in set (0.00 sec)

使用 update 語句進行記錄更新

mysql> ?update money set ?balance=balance-500 where userid = 15;
?Query OK, 1 row affected (0.35 sec)
?Rows matched: 1 ?Changed: 1 ?Warnings: 0

mysql> select * from emp where deptno=15;
?+------+----------+----------+
?| userid |username| ?balance |
?+------+----------+----------+
?| 15 ? | ?馬云 ? ?| 14500.00 |
?+------+-------+-------------+
?1 row in set (0.00 sec)

修改多個字段

mysql> update money set ?balance=balance-500,username='李文凱' where userid = 15;
?Query OK, 1 row affected (0.00 sec)
?Rows matched: 1 ?Changed: 1 ?Warnings: 0

mysql> select * from emp where deptno=15;
?+------+----------+----------+
?| userid |username| ?balance |
?+------+----------+----------+
?| 15 ? |王寶強 ? ?| 14500.00 |
?+------+-------+-------------+
?1 row in set (0.00 sec)

同時對兩個表進行更新

userid usernamebalance
馬云15000.00
Chen He1234131.00
類別詳細(xì)解示
基本語法update 表1,表2 set 字段1=值1,字段2=值2,字段n=值n where 條件
示例update money m,user u m.balance=m.balance*u.age where m.userid=u.id;
示例說明修改money,將money表的別名設(shè)置為m;user表的別名設(shè)置為u;將m表的余額改為m表的balance*用戶表的age。執(zhí)行條件是:m.userid = u.id

mysql> update money m,user u m.balance=m.balance*u.age where m.userid=u.id;

Continuing Learning
||
<?php echo "Hello Mysql"; ?>
submitReset Code