I have a form where they can create/delete/modify records and I an currently coding the modify part. I am doing something like this:
SELECT id FROM foo WHERE id="bar";
if I get any results, it exists, so:
UPDATE foo SET id="barf" WHERE id="bar";
else:
INSERT INTO foo VALUES ("barf", null, null);
This method will work, but it seem like this would be so common that there would be a commen that updates a record if it exists, and inserts it otherwise. Does such a command exist?