0

I have a database table which stores the status of my heating system (0/1). whenever the states changes, i have a new rows in the table with timestamp and new status (0/1). the problem is that, sometimes the software puts duplicate rows in the tables.

So I'd need a query/script which would delete all the duplicate rows, where duplicate means that there are two following rows with the same state.

I'd appreciate whoever helps me.

EDIT:

I forgot to say that I'm using MySQL as DBMS

An example of data is the following:

++++++++++++++++++++++++++
+    ID    +    Status   +
++++++++++++++++++++++++++
+    1     +    0        +
+    2     +    1        +
+    3     +    0        +
+    4     +    0        +
+    5     +    0        +
+    6     +    1        +
+    7     +    1        +
++++++++++++++++++++++++++

When I apply the query, I need to get the following:

++++++++++++++++++++++++++
+    ID    +    Status   +
++++++++++++++++++++++++++
+    1     +    0        +
+    2     +    1        +
+    3     +    0        +
+    6     +    1        +
++++++++++++++++++++++++++
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user3520818
  • 131
  • 1
  • 2
  • 5

0 Answers0