Focus on cloud service provider activities
Notes on website operation and maintenance

Record MySQL addition, deletion, modification and query statements and common methods

For the usage of the MYSQL database, we usually use the command statements of adding, deleting, and modifying. The general usage includes these. The simple record of Laozuo is as follows.

1. Insert data:

Single insertion: INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,...);

Batch insert: INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,...), (value1, value2,...);

2. Query data (SELECT):

Basic query: SELECT column1, column2, ... FROM table_name WHERE condition;

Fuzzy query: SELECT column1, column2, ... FROM table_name WHERE column LIKE 'value%';

Sort query: SELECT column1, column2, ... FROM table_name ORDER BY column ASC/DESC;

Aggregate function query: SELECT function (column) FROM table_name;

3. Update data:

Update a single field: UPDATE table_name SET column=value WHERE condition;

Update multiple fields: UPDATE table_name SET column1=value1, column2 = value2, ... WHERE condition;

4. Delete data:

Delete a specific line: DELETE FROM table_name WHERE condition;

Clear table data: DELETE FROM table_name;

Delete the entire table: DROP TABLE table_name;

When operating the database, it is necessary to write corresponding SQL statements according to the specific business requirements and data table structure, and reasonably use functions such as transactions and indexes to improve the efficiency and performance of the database. At the same time, we should also pay attention to the security of the database to avoid security vulnerabilities such as SQL injection.

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Record MySQL addition, deletion, modification and query statements and common methods


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge