On Aug 20, 2012, at 7:28 PM, Mitchell Hashimoto wrote:
> Hello,
>
> I have a need to perform an "upsert" query with PostgreSQL. the following SQL
> query achieves this goal:
>
> WITH upsert AS (
> UPDATE metric k SET k.count = k.count + 5
> WHERE event = "foo" AND interval = "D" and date =
Hello,
I have a need to perform an "upsert" query with PostgreSQL. the following
SQL query achieves this goal:
WITH upsert AS (
UPDATE metric k SET k.count = k.count + 5
WHERE event = "foo" AND interval = "D" and date = "whatever"
RETURNING k.*
)
INSERT INTO metric (event, interval, date, c