Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

HOWTO? if it exists, increment it, else, insert it



I can't seem to get CASE to work for me here and every example that I see is using CASE in a completely different way.

have a table:

    day(default CURRENT_DATE),   user,   count_of_a,    count_of_b

index is ("day", user)


What is the best postgres way to handle updating this table?

I basically need to say,

    if (day,user) exists, then increment count A
    else insert day, user, and count_a = 1.



thank you in advance




Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group