How to delete a certain row from mysql table with same column values?

前端 未结 6 923
庸人自扰
庸人自扰 2020-12-07 10:37

I have a problem with my queries in MySQL. My table has 4 columns and it looks something like this:

id_users    id_product    quantity    date
 1                     


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 10:42

    All tables should have a primary key (consisting of a single or multiple columns), duplicate rows doesn't make sense in a relational database. You can limit the number of delete rows using LIMIT though:

    DELETE FROM orders WHERE id_users = 1 AND id_product = 2 LIMIT 1
    

    But that just solves your current issue, you should definitely work on the bigger issue by defining primary keys.

提交回复
热议问题