# Selecting Data

- [DUAL](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/dual.md): Understand the DUAL table. This dummy table allows selecting values without referencing a real table, often used for calculations or retrieving system variables.
- [FOR UPDATE](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/for-update.md): Lock rows for write operations. This clause prevents other transactions from modifying or reading the selected rows until the current transaction ends.
- [GROUP BY](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/group-by.md): Group result sets by one or more columns. Learn to aggregate data using functions like SUM, COUNT, and AVG in conjunction with grouping.
- [LIMIT](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/limit.md): Complete LIMIT clause reference: LIMIT n, LIMIT offset,row\_count, LIMIT row\_count OFFSET offset syntax, ORDER BY result handling, and UPDATE replication safety.
- [LOCK IN SHARE MODE](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/lock-in-share-mode.md): Read rows with a shared lock. This clause ensures rows remain unchanged by other transactions while allowing other sessions to read them.
- [ORDER BY](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/order-by.md): Complete ORDER BY clause: sort SELECT/UPDATE/DELETE results with ASC/DESC, multiple expressions, integer column positions, GROUP BY/LIMIT usage.
- [PROCEDURE](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/procedure.md): Pass query results to a C procedure. This clause allows processing the result set on the server side before returning it to the client.
- [SELECT](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select.md): Complete guide to SELECT queries in MariaDB. Complete syntax reference for joins, subqueries, WHERE clauses, GROUP BY, and aggregate functions.
- [SELECT INTO DUMPFILE](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-into-dumpfile.md): Export a single row to a file without formatting. This statement writes raw binary data, such as BLOBs, directly to a file on the server.
- [SELECT INTO OUTFILE](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-into-outfile.md): Complete guide to SELECT queries in MariaDB. Complete syntax reference for joins, subqueries, WHERE clauses, GROUP BY, and aggregate functions.
- [SELECT ... OFFSET ... FETCH](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-offset-fetch.md): Pagination using standard SQL syntax. This clause limits the number of rows returned and skips a specified number of rows, similar to LIMIT.
- [SELECT WITH ROLLUP](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-with-rollup.md): Generate super-aggregate summaries. This modifier adds extra rows to the result set representing subtotals and grand totals for grouped columns.
- [Common Table Expressions (CTE)](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions.md): Learn about Common Table Expressions (CTEs) in MariaDB Server. This section explains how to use CTEs for complex, readable, and reusable subqueries, simplifying data selection and manipulation.
- [Recursive Common Table Expressions Overview](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions/recursive-common-table-expressions-overview.md): Process hierarchical data using recursive CTEs. These expressions reference themselves to repeatedly execute a subquery, perfect for traversing tree structures or generating sequences.
- [Non-Recursive Common Table Expressions Overview](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions/non-recursive-common-table-expressions-overview.md): Define simple temporary result sets. Non-recursive CTEs act like query-local views, improving readability by allowing you to define and reuse subqueries within a single statement.
- [WITH](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/common-table-expressions/with.md): Complete WITH clause reference: WITH \[RECURSIVE] AS (SELECT...) syntax, recursive CTE support, CYCLE...RESTRICT cycle detection, and max\_recursive\_iterations.
- [Joins](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins.md): Retrieve data from multiple tables based on related columns. This section covers INNER, LEFT, RIGHT, and CROSS JOIN syntax and usage.
- [JOIN Syntax](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins/join-syntax.md): Complete reference for JOIN Syntax in MariaDB. Complete syntax guide with all options, clauses, and practical examples with comprehensive examples and best.
- [Comma vs JOIN](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins/comma-vs-join.md): Compare implicit and explicit join syntax. This article explains why using the explicit JOIN syntax with an ON clause is preferred over comma-separated tables for readability and precedence.
- [Set Operations](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations.md): SQL set operations combine the results of multiple query blocks in a single result, using the standard SQL operators EXCEPT, INTERSECT, and UNION, and the Oracle operator MINUS.
- [Precedence Control in Table Operations](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/precedence-control-in-table-operations.md): Control the execution order of UNION, EXCEPT, and INTERSECT operations. Learn how to use parentheses to define explicit operation priority.
- [EXCEPT](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/except.md): Return rows from the first result set that do not appear in the second. This set operator performs a subtraction of two datasets.
- [INTERSECT](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/intersect.md)
- [MINUS](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/minus.md): Oracle-compatible synonym for the EXCEPT operator. It returns rows from the first query that are not present in the second query.
- [UNION](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/union.md): Combine results from multiple SELECT statements into a single result set. This operator can optionally remove duplicates or include all rows.
- [Subqueries](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries.md): Nest queries within other SQL statements. Learn to use scalar, column, row, and table subqueries to filter or calculate data dynamically.
- [Subqueries With ALL](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-and-all.md): Compare a value against all results from a subquery. The ALL operator returns TRUE if the comparison holds for every row returned by the subquery.
- [Subqueries With ANY and SOME](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-and-any.md): Compare a value against any result from a subquery. The ANY (or SOME) operator returns TRUE if the comparison holds for at least one row.
- [Subqueries with IN and NOT IN](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-with-in-and-not-in.md)
- [Subqueries With EXISTS](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-and-exists.md): Test for the existence of rows. The EXISTS operator returns TRUE if the subquery returns at least one row, often used for correlated subqueries.
- [Subqueries With JOINs](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-and-joins.md): Understand when to use subqueries versus joins. This guide explains performance implications and how to rewrite subqueries as joins for efficiency.
- [Subqueries in a FROM Clause (Derived Tables)](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-in-a-from-clause-derived-tables.md): Use a subquery as a temporary table. Derived tables allow you to select from the result set of another query within the FROM clause.
- [Row Subqueries](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-row-subqueries.md): Retrieve a single row of multiple values. A row subquery returns a tuple that can be compared against a row constructor in the outer query.
- [Scalar Subqueries](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subqueries-scalar-subqueries.md): Return a single value. A scalar subquery produces a one-row, one-column result that can be used anywhere a constant or expression is valid.
- [Subquery Limitations](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/subqueries/subquery-limitations.md): Review restrictions on subquery usage. This page details unsupported operations, such as modifying a table while selecting from it in a subquery.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
