how can i avoid to add duplicated entry in my database that is based on date? where instead of inserting again the duplicate entry, i will just update the old data to be deactivated and insert the new duplicate entry.
Here is the structure
Price table
id date_created Value is_active
1 2019-10-01 1:00:00 25 0
2 2019-10-05 2:00:00 30 0
but imagine that the user added a duplicated data again for the Price table which is like this.
2019-10-05 3:00:00
so what i want to do is to update the old entry that has the same date of the user entry to be is_active 1 and insert the new entry.
is there a way to do this? doing this on PHP is really complicated for me because of the use of looping, but i think there is a way in MYSQL which i cant figure it out.