Re: [SQL] Using regexp_matches in the WHERE clause

2013-08-29 Thread David Johnston
spulatkan wrote > so following is enough to get the rows that matches regular expression > This is bad form even if it works. If the only point of the expression is to filter rows it should appear in the WHERE clause. The fact that regexp_matches(...) behaves in this way at all is, IMO, a flaw

Re: [SQL] Using regexp_matches in the WHERE clause

2013-08-29 Thread spulatkan
I noticed that regexp_matches already returns the rows which matches the regular expression now when I make a full table select query but if I make a search with regexp_matches, it only returns rows that matches regular expression on pgadmin the column type is shown as text[] thus I also do no

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

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 >

[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