Menu

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.

  1. 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.
  2. 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.
  3. 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.
  4. MySQL SELECT

    Learn MySQL SELECT syntax for choosing columns, filtering rows, sorting results, using DISTINCT, and limiting results safely.
  5. MySQL WHERE

    Filter MySQL rows with WHERE; combine conditions using AND, OR, and NOT, and compare values with IN, LIKE, BETWEEN, and IS NULL.
  6. MySQL CTE

    Learn MySQL CTE syntax with WITH, reuse named query results, chain CTEs, and understand their scope and common rules.
  7. MySQL Recursive CTE

    Learn MySQL recursive CTE syntax with number sequences and hierarchy traversal, including stop conditions and recursion limits.
  8. MySQL AND

    This article describes how to use the AND operator in the WHERE clause to combine multiple query conditions.
  9. MySQL OR

    This article describes how to use the OR operator in the WHERE clause to combine multiple query conditions.
  10. MySQL IN

    In this article, we describes how to use MySQL IN operator to test whether a value is included in a list.
  11. MySQL NOT IN

    Learn MySQL NOT IN with value lists and subqueries, how NULL changes the result, and when NOT EXISTS is safer.
  12. MySQL BETWEEN

    Filter MySQL values within an inclusive range using BETWEEN or exclude it with NOT BETWEEN; learn type, NULL, and date-boundary behavior.
  13. MySQL LIKE

    In this article, you will learn MySQL LIKE operator and its use cases.
  14. MySQL IS NULL

    This article describes the syntax and usage of MySQL IS NULL operator.
  15. MySQL EXISTS

    Use MySQL EXISTS to test for matching rows in a subquery, compare it with IN and NOT EXISTS, and understand NULL behavior.
  16. MySQL ORDER BY

    In this article, we describe how to use MySQL ORDER BY clause to sort the result set of the SELECT statement.
  17. MySQL LIMIT

    This article describes how to limit the number of rows of result set using the MySQL LIMIT clause.
  18. MySQL DISTINCT

    This article describes how to remove duplicate rows in the result using MySQL DISTINCT keyword.
  19. MySQL JOIN

    In this article, we will introduce MySQL inner joins, left joins, right joins, and cross joins.
  20. 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.
  21. 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.
  22. MySQL HAVING

    Learn how MySQL HAVING filters grouped results, how it differs from WHERE, and how to filter groups with COUNT() and SUM().
  23. MySQL UNION

    Learn MySQL UNION syntax, duplicate handling, result ordering, and the INTERSECT and EXCEPT operators added in MySQL 8.0.31.
  24. MySQL ALIAS

    Learn MySQL column, table, and derived-table aliases, including where column aliases can be used and why derived tables need an alias.
  25. MySQL subqueries

    This article describes what MySQL subqueries are and how to write SQL statements using subqueries.
  26. MySQL INSERT

    Learn MySQL INSERT syntax, column lists, multi-row values, defaults, INSERT IGNORE, and fixes for common insert errors.
  27. MySQL INSERT Multiple Rows

    Insert multiple rows with one MySQL INSERT statement. Learn VALUES syntax, column matching, and packet-size limits for larger batches.
  28. 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.
  29. 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.
  30. 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.
  31. 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.
  32. 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.
  33. MySQL DELETE JOIN

    Learn MySQL multi-table DELETE JOIN syntax, preview rows before deletion, and use INNER JOIN or LEFT JOIN safely.
  34. 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.
  35. 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.
  36. MySQL Transactions

    Learn MySQL transaction syntax with START TRANSACTION, COMMIT, and ROLLBACK, plus autocommit, InnoDB, and implicit-commit behavior.
  37. MySQL REPLACE

    In this article, you will learn about MySQL REPLACE statement and how to use it to insert rows into a table.
  38. MySQL Prepared Statements

    Learn MySQL prepared statement syntax, bind changing values safely, reuse a query, and understand why placeholders cannot replace identifiers.
  39. 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.
  40. UPSERT

    Learn MySQL UPSERT syntax with INSERT … ON DUPLICATE KEY UPDATE, including row aliases, the legacy VALUES() form, and unique-key caveats.
  41. 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.