MySQL: Basic CRUD Command

These are the essential CRUD commands for MySQL.

Be careful with UPDATE and DELETE operations by using the appropriate WHERE clause to avoid unintended data changes or deletions.

CREATE

Create table

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(100),
    email VARCHAR(100),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Insert data into the table

INSERT INTO users (username, email) 
VALUES ('john_doe', '[email protected]');

READ

Select all data from table

SELECT * FROM users;
SELECT username, email FROM users;

Select data with a specific condition

Select data with ordering

Join data from multiple tables

UPDATE

Update data in the table

DELETE

Delete data from the table

Delete all data from the table (use with caution!)

Check this python code for automation using python

Last updated