[SQL] update multiple columns with multiple values

2012-02-10 Thread ssylla
Dear list, I am trying to update all rows of a column ('parent') based on a subquery that returns me the first four digits of another column ('id'): After executing, I get the following error-message: I am not quite sure about that, but maybe I need to construct a function to fulfill this ta

[SQL] update column

2012-02-10 Thread ssylla
Dear list, sorry, I already posted this, but it did not seem to have been accepted by the mailing list. So here's my second try: I need to update all rows of a column ('parent') based on a subquery that returns me the first four digits of another column ('id'): UPDATE admin SET parent=(SELECT SU

[SQL] update column with multiple values

2012-02-10 Thread ssylla
Dear list, sorry, I already posted this, but it did not seem to have been accepted by the mailing list. So here's my second try: I need to update all rows of a column ('parent') based on a subquery that returns me the first four digits of another column ('id'): UPDATE admin SET parent=(SELECT SU

[SQL] query two tables using same lookup table

2012-07-22 Thread ssylla
Dear list, assuming I have two tables as follows t1: id_project|id_auth 1|1 2|2 t2: id_project|id_auth 1|2 2|1 and a lookup-table: t3 id_auth|name_auth 1|name1 2|name2 Now I want to query t1 an t2 using the 'name_auth' column of lookup-table t3, so that I get the following out

[SQL] output query on many to many relationship into several columns

2012-11-27 Thread ssylla
Dear list, assuming I have the following n:n relationship: t1: t2: intermediary table: t3 How can I create an output like this: -- View this message in context: http://postgresql.1045698.n5.nabble.com/output-query-on-many-to-many-relationship-into-several-columns-tp5733692.html Sen

[SQL] select on many-to-many relationship

2012-11-27 Thread ssylla
Dear list, assuming I have the following n:n relationship: t1: id_project 1 2 t2: id_product 1 2 intermediary table: t3 id_project|id_product 1|1 1|2 2|1 How can I create an output like this: id_project|id_product1|id_product2 1|1|2 2|1|NULL -- View this message in context: http://postgre

Re: [SQL] update column based on postgis query on anther table

2013-07-16 Thread ssylla
Hi Tom, I tried changing the trigger to be BEFORE instead of AFTER: create trigger test1_point_get_id_test1_poly before insert or update on test1_point for each row execute procedure test1_point_get_id_test1_poly(); But the problem persits, the column id_test1_poly remains empty. Stefan --

[SQL] detect initiator of update/delete action

2013-09-20 Thread ssylla
Dear list, I want to create a function on a table that does something before deletion on a table, e.g. like create or replace function table1_del() returns trigger as $$ begin update table1 set column1= substr(column2,1,10); insert into table1_hist values (