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 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:
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...)
For example, to insert data into the users
table:
INSERT INTO users (name, email, age) VALUES ('John Doe', 'john.doe@example.com', 30)
DELETE
To delete from MySQL To delete data from the table, you can use the DELETE FROM
statement. The syntax is as follows:
DELETE FROM table_name WHERE condition
For example, to delete a specific user from the users
table:
DELETE FROM users WHERE id = 1
Update (UPDATE)
To update data in a MySQL table, you can use the UPDATE
statement. The syntax is as follows:
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition
For example, update the age of the user in the users
table:
UPDATE users SET age = 31 WHERE id = 1
Query (SELECT)
To To select data from a MySQL table, you can use the SELECT
statement. The syntax is as follows:
SELECT column1, column2, ... FROM table_name WHERE condition
For example, to select all users from the users
table:
SELECT * FROM users
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!