Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> INSERT INTO if UPDATE SET fails (MySQL)

INSERT INTO if UPDATE SET fails (MySQL)

From: Tor Houghton <torh_at_nextel.no>
Date: 1998/10/15
Message-ID: <36265ADC.1217213@nextel.no>#1/1

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US