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:
Category | Detailed explanation |
---|---|
Basic syntax | update table name set field 1=value 1, field 2=value 2, field n=value n where conditions |
Example | update money set balance=balance-500 where userid = 15; |
Example description | Modify 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:
userid | username | balance |
---|---|---|
王寶強 | 50000.00 | |
黃曉明 | 150000000.00 | |
馬云 | 15000.00 | |
Chen He | 1234131.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 |
Continuing Learningmysql> update money m,user u m.balance=m.balance*u.age where m.userid=u.id;
- Course Recommendations
- Courseware download
-
ElementaryPHP introductory tutorial one: Learn PHP in one week
462423 people are watching -
ElementaryPHP introductory video tutorial one Learn PHP in one week
260247 people are watching -
ElementaryScala Tutorial
13737 people are watching -
ElementaryCSS Online Manual
82244 people are watching -
ElementarySVG Tutorial
13127 people are watching -
ElementaryAngularJS Chinese Reference Manual
24571 people are watching -
ElementaryGo language tutorial manual
27432 people are watching -
ElementaryRedis command operation Chinese manual
57879 people are watching -
ElementaryPython 3 Tutorial
87560 people are watching -
ElementaryXML DOM tutorial
21038 people are watching -
ElementaryMemcached command operation manual
17777 people are watching -
ElementaryXSLT tutorial
9827 people are watching
Students who have watched this course are also learning
- Let's briefly talk about starting a business in PHP
- Quick introduction to web front-end development
- Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
- Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
- Login verification and classic message board
- Computer network knowledge collection
- Quick Start Node.JS Full Version
- The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
- Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)