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

From: Brian Neu <proclivity76(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: HOWTO? if it exists, increment it, else, insert it
Date: 2007-01-25 17:06:25
Message-ID: 280592.60721.qm@web51912.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message A. Kretschmer 2007-01-25 17:25:07 Re: HOWTO? if it exists, increment it, else, insert it
Previous Message Neil Bibbins 2007-01-25 16:53:41 Windows 2K Installation difficulties...