MySQL Basics
Learn core MySQL operations with practical guides for queries, joins, inserts, updates, deletes, transactions, and common SQL expressions.
This section describes the basic operations of data manipulation in MySQL, including inserting data, deleting data, modifying data and querying data.
-
MySQL INNER JOIN
Learn how MySQL INNER JOIN returns matching row pairs, use ON or USING, and understand how NULL and one-to-many matches affect results. -
MySQL ON DELETE CASCADE
Learn how MySQL ON DELETE CASCADE removes matching child rows, with an InnoDB example and a query to inspect cascade rules. -
MySQL LEFT JOIN
Learn how MySQL LEFT JOIN keeps every row from the left table, how to find unmatched rows, and why ON and WHERE filters differ. -
MySQL SELECT
Learn MySQL SELECT syntax for choosing columns, filtering rows, sorting results, using DISTINCT, and limiting results safely. -
MySQL WHERE
Filter MySQL rows withWHERE; combine conditions usingAND,OR, andNOT, and compare values withIN,LIKE,BETWEEN, andIS NULL. -
MySQL CTE
Learn MySQL CTE syntax with WITH, reuse named query results, chain CTEs, and understand their scope and common rules. -
MySQL Recursive CTE
Learn MySQL recursive CTE syntax with number sequences and hierarchy traversal, including stop conditions and recursion limits. -
MySQL AND
This article describes how to use theANDoperator in theWHEREclause to combine multiple query conditions. -
MySQL OR
This article describes how to use theORoperator in theWHEREclause to combine multiple query conditions. -
MySQL IN
In this article, we describes how to use MySQLINoperator to test whether a value is included in a list. -
MySQL NOT IN
Learn MySQL NOT IN with value lists and subqueries, how NULL changes the result, and when NOT EXISTS is safer. -
MySQL BETWEEN
Filter MySQL values within an inclusive range usingBETWEENor exclude it withNOT BETWEEN; learn type, NULL, and date-boundary behavior. -
MySQL LIKE
In this article, you will learn MySQLLIKEoperator and its use cases. -
MySQL IS NULL
This article describes the syntax and usage of MySQLIS NULLoperator. -
MySQL EXISTS
Use MySQL EXISTS to test for matching rows in a subquery, compare it with IN and NOT EXISTS, and understand NULL behavior. -
MySQL ORDER BY
In this article, we describe how to use MySQLORDER BYclause to sort the result set of the SELECT statement. -
MySQL LIMIT
This article describes how to limit the number of rows of result set using the MySQL LIMIT clause. -
MySQL DISTINCT
This article describes how to remove duplicate rows in the result using MySQLDISTINCTkeyword. -
MySQL JOIN
In this article, we will introduce MySQL inner joins, left joins, right joins, and cross joins. -
MySQL SELF JOIN
Learn how MySQL SELF JOIN uses table aliases to compare rows in one table, with an employee-manager hierarchy and pair-matching example. -
MySQL GROUP BY
Learn MySQL GROUP BY syntax to aggregate rows by one or more columns, filter groups with HAVING, sort summaries, and use LIMIT. -
MySQL HAVING
Learn how MySQL HAVING filters grouped results, how it differs from WHERE, and how to filter groups with COUNT() and SUM(). -
MySQL UNION
Learn MySQL UNION syntax, duplicate handling, result ordering, and the INTERSECT and EXCEPT operators added in MySQL 8.0.31. -
MySQL ALIAS
Learn MySQL column, table, and derived-table aliases, including where column aliases can be used and why derived tables need an alias. -
MySQL subqueries
This article describes what MySQL subqueries are and how to write SQL statements using subqueries. -
MySQL INSERT
Learn MySQL INSERT syntax, column lists, multi-row values, defaults, INSERT IGNORE, and fixes for common insert errors. -
MySQL INSERT Multiple Rows
Insert multiple rows with one MySQL INSERT statement. Learn VALUES syntax, column matching, and packet-size limits for larger batches. -
MySQL INSERT IGNORE
Learn how MySQL INSERT IGNORE handles duplicate keys and invalid values, how to inspect warnings, and when to use an upsert instead. -
MySQL INSERT INTO SELECT
Use MySQL INSERT INTO SELECT to copy query results into an existing table, with examples for column matching, filtering, and duplicate keys. -
Import CSV into MySQL
Import a CSV file into a MySQL table with LOAD DATA, including headers, column mapping, line endings, LOCAL access, and warnings. -
Export MySQL to CSV
Export MySQL query results to a CSV-style file with SELECT INTO OUTFILE, including secure_file_priv, permissions, quoting, and line endings. -
MySQL DELETE
Learn MySQL DELETE syntax to remove rows with WHERE, ORDER BY, and LIMIT, and understand single-table aliases and multi-table DELETE JOIN. -
MySQL DELETE JOIN
Learn MySQL multi-table DELETE JOIN syntax, preview rows before deletion, and use INNER JOIN or LEFT JOIN safely. -
MySQL UPDATE Statement: Syntax and Examples
Learn MySQL UPDATE syntax and examples for changing one or more columns, targeting rows with WHERE, and using subqueries safely. -
MySQL UPDATE JOIN: Update Rows from Another Table
Use MySQL UPDATE with INNER JOIN or LEFT JOIN to update rows from related tables, with syntax and a self-contained example. -
MySQL Transactions
Learn MySQL transaction syntax with START TRANSACTION, COMMIT, and ROLLBACK, plus autocommit, InnoDB, and implicit-commit behavior. -
MySQL REPLACE
In this article, you will learn about MySQLREPLACEstatement and how to use it to insert rows into a table. -
MySQL Prepared Statements
Learn MySQL prepared statement syntax, bind changing values safely, reuse a query, and understand why placeholders cannot replace identifiers. -
Latest Row per Group
Return the latest MySQL row per group with ROW_NUMBER() or MAX() and a join; handle timestamp ties and MySQL 5.7. -
UPSERT
Learn MySQL UPSERT syntax with INSERT … ON DUPLICATE KEY UPDATE, including row aliases, the legacy VALUES() form, and unique-key caveats. -
Top N per Group
Use ROW_NUMBER(), RANK(), and PARTITION BY to return the top N MySQL rows within each group, handle ties, and support MySQL 5.7.