I am trying to create a timesheet and want to have the following SQL Query done:
I have the fields datebeginning and dateending and jobid and I want to only add a new one if no open one exists for a given job id and if not I want the query to update the fild dateending for the given id. Is there a way to do that without using PHP to first Select and then Insert or Update?
Use
INSERT ... ON DUPLICATE KEY UPDATE ..., see http://dev.mysql.com/doc/refman/5.0/en/insert.html