Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> INSERT INTO if UPDATE SET fails (MySQL)
Hi all,
I couldn't find an general SQL group, so I will try here. Shoot me if I'm babbling nonsense.
I've got the following problem. I need to do
UPDATE table SET counter=counter+A WHERE datestamp=NOW() AND constraint=B;
If this meets the set criteria, this is no problem. But what I want is to create the table record if it doesn't exist. I thought I might use IF NOT EXISTS, but can't seem to get it to work.
Some more information about the above, if unclear:
A is an arbitrary INT(11). B is an arbitrary INT(11).
The table 'table' is defined by the following:
CREATE TABLE table (
datestamp DATE NOT NULL, constraint INT, counter INT, KEY (date)
Hope someone can help!
Thanks in advance.
Tor Houghton. Received on Thu Oct 15 1998 - 00:00:00 CDT