Change column position
ALTER TABLE table_name MODIFY COLUMN column_last_name VARCHAR(40) AFTER column_first_name;
Count rows in a table
SELECT COUNT(*) FROM table_name;
Create a new table in the database
CREATE TABLE employees (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
email VARCHAR(100),
hire_date DATE,
salary DECIMAL(10, 2)
);
Insert data into an existing table in the database
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
Select data from an existing table in the database
SELECT * FROM table_name;
Select specific columns from an existing table in the database
SELECT column1, column2 FROM table_name;
Strip HTML tags
$content = '<h1>Lorem Ipsum</h1> <p><a href="#">Lorem ipsum dolor sit amet... </a><p>';
$content_without_tags = strip_tags($content);
Strip all HTML and PHP tags, except <p>
and <a>
$content = '<h1>Lorem Ipsum</h1> <p><a href="#">Lorem ipsum dolor sit amet... </a><p>';
$content_without_tags = strip_tags($content, '<p><a>');
Strip all HTML and PHP tags from a MySQL table row
$content = $row["content"];
$content_without_tags = strip_tags($content);
Update a column to lowercase
UPDATE table_name SET column_name = LOWER(column_name);
Update data in an existing table in the database
UPDATE table_name SET column1 = value1 WHERE condition;