Optional. Returns all matching rows
Optional. Removes duplicates from the result set. Learn more about DISTINCT clause.
Optional. Synonym for DISTINCT. Removes duplicates from the result set.
Optional. It tells MySQL to run the SELECT before any UPDATE statements that are waiting for the same resource. It may be used with MyISAM, MEMORY and MERGE tables that use table-level locking.
Optional. It tells MySQL to join the tables in the order that they are listed in the FROM clause.
Optional. Uses fast temporary tables to store results (used with DISTINCT and GROUP BY).
Optional. Prefers sorting rather than using a temporary table to store results (used with DISTINCT and GROUP BY).
Optional. Uses temporary tables to store results (can not be used with subqueries).
Optional. Stores the results in the query cache.
Optional. Does not store the results in the query cache.
Optional. Calculates how many records are in the result set (not taking into account the LIMIT modifier) which can then be retrieved using the FOUND_ROWS function.
The columns or calculations that you wish to retrieve. Use * if you wish to select all columns.
The tables that you wish to retrieve records from. There must be at least one table listed in the FROM clause.
- WHERE conditions
Optional. The conditions that must be met for the records to be selected.
- GROUP BY expressions
Optional. It collects data across multiple records and groups the results by one or more columns. Learn more about the GROUP BY clause.
- HAVING condition
Optional. It is used in combination with the GROUP BY to restrict the groups of returned rows to only those whose the condition is TRUE. Learn more about the HAVING clause.
- ORDER BY expression
Optional. It is used to sort the records in your result set. Learn more about the ORDER BY clause.
Optional. If LIMIT is provided, it controls the maximum number of records to retrieve. At most, the number of records specified by number_rows will be returned in the result set. The first row returned by LIMIT will be determined by offset_value.
Optional. If provided, procedure_name is the name of the procedure that should process the data in the result set.
Optional. If provided, it allows you to write the result set to either a file or variable.
|INTO OUTFILE 'filename' options
||Writes the result set to a file called filename on the server host. For options, you can specify:
FIELDS ESCAPED BY 'character'
FIELDS TERMINATED BY 'character' [ OPTIONALLY ENCLOSED BY 'character' ]
LINES TERMINATED BY 'character'
where character is the character to display as the ESCAPE, ENCLOSED, or TERMINATED character. For example:
SELECT supplier_id, supplier_name
INTO OUTFILE 'results.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '
|INTO DUMPFILE 'filename'
||Writes one row of the result set to a file called filename on the server host. With this method, there is no column termination, no line termination, or escape processing.
|INTO @variable1, @variable2, ... @variable_n
||Writes the result set to one or more variables, as specified by @variable1, @variable2, ... @variable_n
- FOR UPDATE
Optional. Records affected by the query are write-locked until the transaction has completed.
- LOCK IN SHARE MODE
Optional. Records affected by the query can be used by other transactions but can not be updated or deleted by those other transactions.