I\'m trying to implement a SQL query to \"UPDATE if exists else INSERT\"
My table(Allowance) is as below:
Allowance
EmployeeID int(8) PK Year year
The below query will fulfill your requirement.
INSERT INTO `ALLOWANCE` (`EmployeeID`, `Year`, `Month`, `OverTime`,`Medical`, `Lunch`, `Bonus`, `Allowance`) values (10000001, 2014, 4, 10.00, 10.00, 10.45, 10.10, 40.55) ON DUPLICATE KEY UPDATE `EmployeeID` = 10000001