I have application connecting and getting data from Mysql database.
And i have problem to do this:
Ok, it works, but only if there is field_name2 with valueX
So when there isnt i would execute new statement with INSERT.
I know how to get data from mysql and so on, i just would request some help with already mentioned problem, check if field with given value exist, if yes update it with X in field Y, if not insert new ready entry with proper needed data.
I don't see where exceptions would come into the process. Do a SELECT which looks for the record which may or may not be there; if that query returns zero rows then it isn't there, so do an INSERT. If the query returns a row, then do an UPDATE.