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 |
类别 | 详细解示 |
---|---|
基本语法 | 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表的别名设置为m;user表的别名设置为u;将m表的余额改为m表的balance*用户表的age。执行条件是: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
460067 people are watching -
ElementaryPHP introductory video tutorial one Learn PHP in one week
259080 people are watching -
ElementaryScala Tutorial
13026 people are watching -
ElementaryCSS Online Manual
81491 people are watching -
ElementarySVG Tutorial
12596 people are watching -
ElementaryAngularJS Chinese Reference Manual
24046 people are watching -
ElementaryGo language tutorial manual
26804 people are watching -
ElementaryRedis command operation Chinese manual
57332 people are watching -
ElementaryPython 3 Tutorial
87037 people are watching -
ElementaryXML DOM tutorial
20590 people are watching -
ElementaryMemcached command operation manual
17379 people are watching -
ElementaryXSLT tutorial
9450 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)