sql statement to modify data
In SQL, you can use the UPDATE statement to modify and update the data of one or more tables.
The syntax format is:
UPDATE <表名> SET 字段 1=值 1 [,字段 2=值 2… ] [WHERE 子句 ] [ORDER BY 子句] [LIMIT 子句]
The syntax description is as follows:
: used to specify the name of the table to be updated.
SET clause: used to specify the column name and its column value to be modified in the table. Among them, each specified column value can be an expression or the default value corresponding to the column. If a default value is specified, the column value can be represented by the keyword DEFAULT.
WHERE clause: Optional. Used to limit the rows in the table to be modified. If not specified, all rows in the table will be modified.
ORDER BY clause: optional. Used to limit the order in which rows in a table are modified.
LIMIT clause: Optional. Used to limit the number of rows that are modified.
Note: When modifying multiple column values in a row of data, each value in the SET clause can be separated by commas.
Example:
mysql> UPDATE tb_courses_new -> SET course_name='DB',course_grade=3.5 -> WHERE course_id=2; Query OK, 1 row affected (0.13 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> SELECT * FROM tb_courses_new; +-----------+-------------+--------------+------------------+ | course_id | course_name | course_grade | course_info | +-----------+-------------+--------------+------------------+ | 1 | Network | 4 | Computer Network | | 2 | DB | 3.5 | MySQL | | 3 | Java | 4 | Java EE | | 4 | System | 4 | Operating System | +-----------+-------------+--------------+------------------+ 4 rows in set (0.00 sec)Copy after loginPHP Chinese website has a large number of free SQL tutorials, everyone is welcome to learn!
The above is the detailed content of sql statement to modify data. For more information, please follow other related articles on the PHP Chinese website!
Related labels:source:php.cnStatement of this WebsiteThe content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cnLatest Articles by Author
2020-04-03 18:08:45 2020-04-02 18:10:17 2020-04-01 17:01:16 2020-03-31 18:06:25 2020-03-31 18:00:22 2020-03-31 17:44:20 2020-03-31 17:22:09 2020-03-31 17:09:21 2020-03-31 17:00:48 2020-03-31 16:47:03Latest IssuesSQL Count() also requires 0 I have only one table and I want to count each entry of a tag that starts with 0. Now I tr...From 2024-04-06 19:48:5301449Related TopicsMore>