Skip to content

Instantly share code, notes, and snippets.

@MostafaNorzade
Created October 23, 2019 19:40
Show Gist options
  • Save MostafaNorzade/f569d019bab390242d3692d11296a1e3 to your computer and use it in GitHub Desktop.
Save MostafaNorzade/f569d019bab390242d3692d11296a1e3 to your computer and use it in GitHub Desktop.
<?php
//--- update or insert
INSERT INTO MyGuests (id, lastname) VALUES (2, 'Doe')
ON DUPLICATE KEY UPDATE lastname = 'Doe';
UPDATE MyGuests SET lastname='Doe' WHERE id=2
IF ROW_COUNT()=0
INSERT INTO MyGuests (lastname, id) VALUES ('Doe',2);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment