dimanche 1 février 2015

Sqlite: Insert if not exist, Update if exist

I have a database with 2 tables like this:



cg_resp
id | name | email
1 | George | george@yahoo.com


and



equip_info
id | description | cg_resp_id
1 | Caliper | 1


In the application form I have 2 edit boxes with named edit_resp_name and edit_resp_email


If user insert a new responsible name John with the email john@yahoo.com then during saving I would like to insert a new responsible into cg_resp table


If the user maintain the name George but it's updating the email like george01@gmail.com then I would like to update the cg_resp.id=1


How can be done this in one Sqlite sql sequence?


Aucun commentaire:

Enregistrer un commentaire