Q:

Remove one of duplicate records

This is my DB table table name is food_user. I use mariadb version 10.1.38.

I run the following sql query :
INSERT INTO food_user (NAME,re_date,re_day)
SELECT 'Alex','2019-01-01' + INTERVAL seq DAY,DAYNAME('2019-01-01' + INTERVAL seq DAY)
FROM seq_0_to_364; 

two times. So there are two data of the same date as seen on the screenshot below.

I'd like to remove one of the two same dates.
I try this query. 
DELETE n1 from food_user n1, food_user n2 
where n1.id > n2.id
  and n1.sum=0 and n2.sum=0
  and n1.name='Alex'
  and n2.name='Alex'
  and n1.re_date=?
  and n2.re_date=?;

I don't know the proper query.

A:

Here's how your delete query should look like.
delete from food_user where id in 
(
   select x.id from (select min(id) as id from food_user t group by name, re_date having count(1) = 2) as x
)

