Search code examples
phpmysqldatabasedelete-row

Delete Datebase that duplicate between row


If in database has

First     Last     distance
1          4          0.2         //line 1
2          6          0.5         //line 2
3          7          0.3         //line 3
4          1          0.2         //line 4

If I want delete line 4 because the result is equal line 1, How to write the code?


Solution

  • Sidenote: Posted as a community wiki. I don't want rep from this.

    This is basic MySQL using DELETE with a WHERE clause.

    DELETE FROM table WHERE col_x = 'y'
    

    As per the manual:

    DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name
        [PARTITION (partition_name,...)]
        [WHERE where_condition]
        [ORDER BY ...]
        [LIMIT row_count]