Hi all,
Im using mysql 5.0. I am doing a insert/update query for a particular record. The situation here is, I'm doing a select query first to check whether the given record is present or not, my select query is-->

Code MySQL:
Select Req_Code,Expenditure_Code from Expenditure_Requisition_Detail Where Req_Code = 'R42141620'

If the req_code value is not present in the table, i do an insert query as--->

Code MySQL:
INSERT INTO Expenditure_Requisition_Detail(Req_Code,Payment_By_Branch,Expenditure_Code,Estimated_Cost) VALUES (?,?,?,?)

If the req_code value is present, i do an update query as---->

Code MySQL:
UPDATE Expenditure_Requisition_Detail SET Estimated_Cost = 2000.0 WHERE Payment_By_Branch = 'Lucknow' and Expenditure_Code = '41620101' and Req_Code = 'R42141620'

All this is working fine, but now the problem here is, suppose the req_code is R42141620 and i select a new Expenditure_code(there are many expenditure_code) value 41620105, for the same req_code as compared to 41620101 in the above example, i want a duplicate req_code to be enterred with the new expenditure_code value without changing the existing set up.

The output should be something like this---->

Code:
Req_code      expenditure_code    amount    destination   amount_paid
R42141620	41620101	  10000	    Lucknow	 0
Here if the req_code value is R42141620 and expenditure_code value is 41620101, if i add new amount for the same req_code and expen_code then the value should be updated, and if the req_code is same but the expenditure_code value is say 41620105 then an insert should happen and the result should be something like this---->

Code:
Req_code      expenditure_code    amount    destination   amount_paid
R42141620	41620101	  10000	    Lucknow	   0
         
R42141620	41620105	  12000	    Lucknow	   0
P.S: I understand i have to do a on duplicate key update but i dont want to use it since i dont want the query specific to mysql. I hope i conveyed myself right.

Any help here is appreciated.

regards,
ajos777