Jan 10, 2018

MySQL: DELETE LIMIT Statement

The MySQL DELETE LIMIT statement is used to delete records from a table in MySQL and limit the number of records deleted based on a limit value.

ORDER BY expression
Optional. It is used in the DELETE LIMIT statement so that you can order the results and target those records that you wish to delete.
LIMIT row_count
It specifies a limited number of rows in the result set to delete based on row_count. For example, LIMIT 10 would delete the first 10 rows matching the delete criteria. This is where sort order matters so be sure to use an ORDER BY clause appropriately.

The DELETE statement deletes rows from tbl_name and returns the number of deleted rows. To check the number of deleted rows, call the ROW_COUNT() function 

If the ORDER BY clause is specified, the rows are deleted in the order that is specified. The LIMIT clause places a limit on the number of rows that can be deleted. These clauses apply to single-table deletes, but not multi-table deletes. And you cannot use table alias.

Post a Comment

Featured Post

Datasets

Google Tables helps you search thousands of public Fusion Tables, or millions of public tables from around the web you can import to Fusio...