I have three fields in the database table(serial_no,arrive_date,written_date).My problem is if serial_no and arrive_date already exist in the database, it show say"data already exist". Though serial_no and arrive_date already exist but with a different written_date, then the data should be inserted into the database.

Example

ID Serial_no Arrive_date Written_date
1 ABC 05/05/2014 04/05/2014 --->this is an already existing data
2 ABC 05/05/2014 05/05/2014 --->this is what i want.Though the same Serial_no and Arrive_date but different written_date. Thanks in advance

Member Avatar
diafol

You don't show your code, so it's difficult to know what you're doing. How is the error generated?

You could make it so that the three fields give a combined Primary Key.

However, the date format you use is awkward - you may find it easier to store dates as Y-m-d or even as a unix timestamp. Searching the db via date > or < or BETWEEN becomes far more complicated when using country or continent-specific formats.