I have a table below :
+-----+-------+------+------------+ | ID | RefID | Type | EventTime | +-----+-------+------+------------+ | 101 | 228 | 1 | 1437195633 | | 102 | 228 | 5 | 1437195633 | | 103 | 228 | 1 | 1437195633 | | 104 | 228 | 1 | 1437195442 | | 105 | 228 | 1 | 1437195442 | | 106 | 228 | 5 | 1437195442 | | 107 | 228 | 1 | 1437165634 | | 108 | 228 | 5 | 1437165442 | | 109 | 228 | 1 | 1437165634 | | 110 | 228 | 5 | 1437165442 | +-----+-------+------+------------+
In that I want to stop inserting duplicate
data based on the columns RefID,Type,EventTime
only when value of Type = 1
.
In the above table ID
pair is duplicate (101,103), (104,105), (107,109)
.
If now I will insert another data say :
INSERT INTO table VALUES('',228,1,1437165634);
Then it should not insert
. I am checking while inserting into that table but that is not working as I have checked at the same time 2 insert
query is happening, I need to stop it using UNIQUE key
constraints.