Please consider following table
Table Name: mytable
model_id | event_name | time_of_event |
---|---|---|
9 | CREATE | 2016-01-01 00:00:00 |
9 | UPDATE | 2016-01-01 01:00:00 |
9 | DELETE | 2016-01-01 02:00:00 |
3 | CREATE | 2016-01-01 03:00:00 DUPLICATE |
3 | CREATE | 2016-01-01 03:00:00 DUPLICATE delete this |
3 | DELETE | 2016-01-01 04:00:00 |
How to delete 5th entry from above table i.e. delete row with exactly same value from table. In above example no column is unique.
Please keep in mind that database could be huge and I don't want to recreate or republish data with distinct values into the table.
// Use below code to create above example
CREATE TABLE mytable(
model_id integer,
event_name varchar(7),
time_of_event timestamp
);
INSERT INTO mytable
(model_id, event_name, time_of_event)
VALUES
(9, 'CREATE', '2016-01-01 00:00:00'),
(9, 'UPDATE', '2016-01-01 01:00:00'),
(9, 'DELETE', '2016-01-01 02:00:00'),
(3, 'CREATE', '2016-01-01 03:00:00'),
(3, 'CREATE', '2016-01-01 03:00:00'),
(3, 'DELETE', '2016-01-01 04:00:00');
SELECT * FROM mytable;