We're using PostgreSQL v8.2.3.
Is it possible to get DISTINCT rows from an UPDATE statement using RETURNING clause?
MYTABLE columns are:
- APRIMARYKEYCOLUMN
- ABOOLEANCOLUMN
- COLUMN1
- COLUMN2
- COLUMN3
UPDATE using RETURNING clause query:
UPDATE MYTABLE SET ABOOLEANCOLUMN = true FROM MYTEMPTABLE WHERE EMAIL =
MYTEMPTABLE.EMAIL RETURNING EMAIL, COLUMN1, COLUMN2, COLUMN3;
Here in this case, I expect to return distinct rows from these columns: EMAIL, COLUMN1, COLUMN2, COLUMN3.
I even tried out some ways of getting distinct rows, but it doesn't work. Though I can still solve this at application layer, I'm trying to find whether this could be solved/controlled at query-level. Any different ideas/suggestions are appreciated.
No you can't. RETURNING is great but it's not the same as a normal SELECT statement. RETURNING is record based, not set based. DISTINCT works on a set.