For the complete documentation index, see llms.txt. This page is also available as Markdown.

SQL Clauses

Description

SQL clauses are keywords that specify conditions or modify the behavior of SQL statements. They form the building blocks of SQL queries.

Different Clauses

SELECT Clause:

Specifies the columns to be retrieved.

Example:

SELECT name, salary FROM employees;

FROM Clause:

Specifies the table(s) from which to retrieve the data.

Example:

SELECT name, salary FROM employees;

WHERE Clause:

Filters the rows based on a specified condition.

Example:

GROUP BY Clause:

Groups rows that have the same values in specified columns into aggregated data.

Example:

HAVING Clause:

Filters groups based on a specified condition (used with GROUP BY).

Example:

ORDER BY Clause:

Sorts the result set based on one or more columns.

Example:

JOIN Clause:

Combines rows from two or more tables based on a related column.

Example:

INSERT INTO Clause:

Adds new rows to a table.

Example:

UPDATE Clause:

Modifies existing rows in a table.

Example:

DELETE Clause:

Removes rows from a table.

Example:

LIMIT/OFFSET Clause:

Specifies the number of rows to return or skip (supported in databases like MySQL, PostgreSQL).

Example:

DISTINCT Clause:

Removes duplicate rows from the result set.

Example:

Last updated