1

Possible Duplicate:
Insert, on duplicate update (postgresql)

Is this possible on PostgreSQL:

insert record, if the record doesn't exists
else update existing record

Supposedly that the record will be inserted in this table structure:

[userid - unique] [count]

If there was an existing record, I will just update the count or insert if it doesn't exists

Community
  • 1
  • 1
Mike Montesines
  • 151
  • 4
  • 8

1 Answers1

2

You have to write a Function to do that in PostgreSQL, since there isn't something similar to mysql's INSERT ... ON DUPLICATE KEY UPDATE . Take a look at this function at PostgreSQL official documentation.

aleroot
  • 71,077
  • 30
  • 176
  • 213