Sql query for deleting rows before a certain year

rokr1

How can I delete all the rows before a certain year(say 2012) in MySQL, where the date column is in DATETIME format? ex:

DELETE FROM table_name WHERE date<2012;

Is not working.

Vivek Sadh

You can do it this way:

DELETE FROM tablename WHERE date < '2012-01-01 00:00:00';

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SQL query that removes all rows with certain value?

From Dev

Deleting rows with cells of certain values

From Dev

Query performance increase from deleting rows in SQL database?

From Dev

SQL Query: Deleting rows from PostgreSQL with same values

From Dev

Oracle: sql query for deleting duplicate rows based on a group

From Dev

Excel VBA deleting certain rows with certain conditions

From Dev

SQL Query: Get rows where value of certain column is maximum

From Dev

SQL Query to return count of rows until certain criteria is met

From Dev

Deleting rows with certain keywords of csv file

From Dev

Deleting rows based on cell value in a certain column

From Dev

Deleting rows before a date with datetime-field

From Dev

Find All Rows By A Certain Date/Any Year

From Dev

SQL Sum of certain rows

From Dev

Deleting SQL Rows and DataGrid Rows in Visual Basic

From Dev

Query rows modified in certain timespan

From Dev

Oracle - Query that only checks for a certain year

From Dev

SQL Query - Year by Year Growth of Sales

From Dev

SQL Query - Year by Year Growth of Sales

From Dev

sql query for a certain condition

From Dev

sql query for a certain condition

From Dev

pandas dataframe take rows before certain indexes

From Dev

sql query for fetching correct year

From Dev

SQL query count and distinct year

From Dev

Deleting 1 millions rows in SQL Server

From Dev

SQL Server : deleting rows by month name

From Dev

SQL Stored Procedure Deleting all rows in table

From Dev

Query without value before certain date

From Dev

SQL query: same rows

From Dev

sql query to extract rows