Re: [SQL] select on many-to-many relationship

2012-11-27 Thread Sergey Konoplev
On Tue, Nov 27, 2012 at 2:13 AM, ssylla wrote: > 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 You can use the crostab() function from the tablefunc module (http://www.postgresql.org/docs/9.2/static/tablef

Re: [SQL] select on many-to-many relationship

2012-11-27 Thread Виктор Егоров
2012/11/27 ssylla : > assuming I have the following n:n relationship: > > 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 I'd said the sample is too simplified — not clear which id_

Re: [SQL] Using regexp_matches in the WHERE clause

2012-11-27 Thread David Johnston
On Nov 26, 2012, at 7:13, Thomas Kellerer wrote: > > So I tried: > > SELECT * > FROM some_table > WHERE regexp_matches(somecol, 'foobar') is not null; > > However that resulted in: ERROR: argument of WHERE must not return a set > > Hmm, even though an array is not a set I can partly see

[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

[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

Re: [SQL] Using regexp_matches in the WHERE clause

2012-11-27 Thread Pavel Stehule
2012/11/27 Thomas Kellerer : > Pavel Stehule, 27.11.2012 13:26: > >>> My question is: why I cannot use regexp_matches() in the WHERE clause, >>> even >>> when the result is clearly an integer value? >>> >> >> use a ~ operator instead >> > > So that means, regexp_matches cannot be used as an express

Re: [SQL] Using regexp_matches in the WHERE clause

2012-11-27 Thread Thomas Kellerer
Pavel Stehule, 27.11.2012 13:26: My question is: why I cannot use regexp_matches() in the WHERE clause, even when the result is clearly an integer value? use a ~ operator instead So that means, regexp_matches cannot be used as an expression in the WHERE clause? Regards Thomas -- Sent

Re: [SQL] Using regexp_matches in the WHERE clause

2012-11-27 Thread Pavel Stehule
Hello 2012/11/27 Thomas Kellerer : >> > So I tried: >> > >> > SELECT * >> > FROM some_table >> > WHERE regexp_matches(somecol, 'foobar') is not null; >> > >> > However that resulted in: ERROR: argument of WHERE must not return a >> set >> > >> > Hmm, even though an array is not a set I ca

Re: [SQL] Using regexp_matches in the WHERE clause

2012-11-27 Thread Thomas Kellerer
> So I tried: > > SELECT * > FROM some_table > WHERE regexp_matches(somecol, 'foobar') is not null; > > However that resulted in: ERROR: argument of WHERE must not return a set > > Hmm, even though an array is not a set I can partly see what the problem is > (although given the really co

Re: [SQL] Using regexp_matches in the WHERE clause

2012-11-27 Thread Willem Leenen
Sounds to me like this: http://joecelkothesqlapprentice.blogspot.nl/2007/12/using-where-clause-parameter.html > To: pgsql-sql@postgresql.org > From: spam_ea...@gmx.net > Subject: [SQL] Using regexp_matches in the WHERE clause > Date: Mon, 26 Nov 2012 13:13:06 +0100 > > Hi, > > I stumbl

Re: [SQL] locks problem

2012-11-27 Thread Marcin Krawczyk
Ok I figured it out. I had a prepared transaction holding the locks. The pg_prepared_xacts was helpful. 27-11-2012 10:27, "Marcin Krawczyk" napisał(a): > Hi list, > > I've got a locking problem which prevents me from doing some alters on my > tables. When I looked into pg_locks I saw a lot of ent

[SQL] Using regexp_matches in the WHERE clause

2012-11-27 Thread Thomas Kellerer
Hi, I stumbled over this question on Stackoverflow http://stackoverflow.com/questions/13564369/postgresql-using-column-data-as-pattern-for-regexp-match And my initial reaction was, that this should be possible using regexp_matches. So I tried: SELECT * FROM some_table WHERE regex

[SQL] locks problem

2012-11-27 Thread Marcin Krawczyk
Hi list, I've got a locking problem which prevents me from doing some alters on my tables. When I looked into pg_locks I saw a lot of entries (around 1000) with pid being NULL and almost all of them are AccessShare. Can anyone tell me what might those be and how do I get rid of them ?