Hi. Maybe I miss something but I can't use 'AS' with 'DELETE' (7.4.3) Example:
db=# SELECT * FROM temp1 ; host_id | user_id | raw | uniq ---------+---------+-----+------ 2 | 1 | 125 | 85 2 | 2 | 100 | 50 (2 rows) And there is temp2 just like temp1. db=# DELETE FROM temp1 AS t1 WHERE EXISTS (SELECT 1 FROM temp2 AS t2 WHERE t2.host_id = t1.host_id AND t2.user_id = t1.user_id); ERROR: syntax error at or near "AS" at character 19 but db=# DELETE FROM temp1 WHERE EXISTS (SELECT 1 FROM temp2 AS t2 WHERE t2.host_id = temp1.host_id AND t2.user_id = temp1.user_id); DELETE 1 db=# SELECT * FROM temp1 ; host_id | user_id | raw | uniq ---------+---------+-----+------ 2 | 1 | 125 | 85 (1 row) It make me supply full name of table... Another example with UPDATE db=# UPDATE referer_total AS ref SET ref.raw = ref.raw + u.raw, ref.uniq = ref.uniq + u.uniq FROM temp1 AS u WHERE u.user_id = ref.user_id AND ref.referer = u.referer; ERROR: syntax error at or near "AS" at character 22 db=# UPDATE referer_total SET db-# referer_total.raw = referer_total.raw + u.raw, db-# referer_total.uniq = referer_total.uniq + u.uniq db-# FROM temp1 AS u WHERE u.user_id = referer_total.user_id db-# AND referer_total.referer = u.referer; ERROR: syntax error at or near "." at character 46 So it make me rename temp1's "raw" to something else ("r"), "uniq" too; and 'AS' not possible too. And finally, working version: UPDATE referer_total SET raw = raw + r, uniq = uniq + u FROM temp1 AS u WHERE u.user_id = referer_total.user_id AND referer_total.referer = u.referer; It looks strange, are there any limitations or something else that make it not possible to use 'AS' in 'DELETE' and 'UPDATE'? Of course with described workarounds I can eliminate that problems, but I want to know is it so in 8.x? Or why, if it right behaviour? -- engineer ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend