Home >Database >Mysql Tutorial >How to write mysql add, delete, modify, query command

How to write mysql add, delete, modify, query command

下次还敢
下次还敢Original
2024-04-22 19:39:40861browse

The add, delete, modify and query commands provided by MySQL are: INSERT: insert records into the table, the syntax is INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ... ). Delete (DELETE): delete records from the table, the syntax is DELETE FROM table_name WHERE condition. Change (UPDATE): Update existing records in the table, the syntax is UPDATE table_name SET column1 = value1, column2 =

How to write mysql add, delete, modify, query command

MySQL Add, Delete, Modify and Query Command Guide

MySQL provides a series of commands for performing database operations, including adding, deleting, modifying, and querying. These commands are easy to use and help users manage and manipulate data efficiently.

Increase (INSERT)

The INSERT command is used to insert one or more records into the table. The syntax is as follows:

<code>INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...)</code>

For example:

<code>INSERT INTO customers (name, email)
VALUES ('John Doe', 'john.doe@example.com');</code>

DELETE

The DELETE command is used to delete records from the table. The syntax is as follows:

<code>DELETE FROM table_name
WHERE condition</code>

For example:

<code>DELETE FROM customers
WHERE id = 123;</code>

Change (UPDATE)

The UPDATE command is used to update existing records in the table. The syntax is as follows:

<code>UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition</code>

For example:

<code>UPDATE customers
SET name = 'Jane Doe'
WHERE id = 123;</code>

Check (SELECT)

The SELECT command is used to retrieve data from a table. The syntax is as follows:

<code>SELECT column1, column2, ...
FROM table_name
WHERE condition</code>

For example:

<code>SELECT * FROM customers
WHERE city = 'New York';</code>

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

Statement:
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