Home > Database > Mysql Tutorial > body text

How to add, delete, modify and query mysql

下次还敢
Release: 2024-04-22 19:42:32
Original
377 people have browsed it

Perform CRUD in MySQL: Insert (CREATE): Use the INSERT INTO statement to insert data into the table. Delete (DELETE): Use the DELETE FROM statement to delete data from the table based on conditions. Update (UPDATE): Use the UPDATE statement to update data in the table based on conditions. Query (SELECT): Use the SELECT statement to select data from a table based on conditions.

How to add, delete, modify and query mysql

How to add, delete, modify and query in MySQL

MySQL is a popular relational database management system. Provides CRUD operations on data.

INSERT (CREATE)

To insert data into a MySQL table, you can use the INSERT INTO statement. The syntax is as follows:

<code class="sql">INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...)</code>
Copy after login

For example, to insert data into the users table:

<code class="sql">INSERT INTO users (name, email, age) VALUES ('John Doe', 'john.doe@example.com', 30)</code>
Copy after login

DELETE

To delete from MySQL To delete data from the table, you can use the DELETE FROM statement. The syntax is as follows:

<code class="sql">DELETE FROM table_name WHERE condition</code>
Copy after login

For example, to delete a specific user from the users table:

<code class="sql">DELETE FROM users WHERE id = 1</code>
Copy after login

Update (UPDATE)

To update data in a MySQL table, you can use the UPDATE statement. The syntax is as follows:

<code class="sql">UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition</code>
Copy after login

For example, update the age of the user in the users table:

<code class="sql">UPDATE users SET age = 31 WHERE id = 1</code>
Copy after login

Query (SELECT)

To To select data from a MySQL table, you can use the SELECT statement. The syntax is as follows:

<code class="sql">SELECT column1, column2, ... FROM table_name WHERE condition</code>
Copy after login

For example, to select all users from the users table:

<code class="sql">SELECT * FROM users</code>
Copy after login

The above is the detailed content of How to add, delete, modify and query mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The 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.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!