From: | webb(dot)sprague(at)gmail(dot)com |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Regular expressions and arrays and ANY() question |
Date: | 2007-01-20 22:10:20 |
Message-ID: | 1169331020.695761.100710@11g2000cwr.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I am trying to figure out how to use a regex and an ANY(), without any
luck, to determine if at least one element of an array (on the right)
matches the given constant pattern (on the left).
I think the problem is because the pattern expects to be on the right
side with the target on the left, but I want to do it reversed. (ie I
want 'Corvalli%' like 'Corvallis', but for postgres the only thing is
'Corvallis' like 'Corvalli%'). Has anybody worked around this before?
See below for code. TIA. Feel free to email me directly.
or_gis=# select * from quads_w_cities where 'Corvallis' = any
(cities); -- this works like I want
ohiocode | cities
----------+-------------------------------------
44123e2 | {Albany,Corvallis,Tangent,Estacada}
44123e3 | {Corvallis,Philomath}
(2 rows)
or_gis=# select * from quads_w_cities where 'corv.*' ~ any
(cities); -- I want this to give me something just like the above
ohiocode | cities
----------+--------
(0 rows)
or_gis=# select * from quads_w_cities where 'corv.*' ~~ any
(cities); -- etc...
ohiocode | cities
----------+--------
(0 rows)
or_gis=# select * from quads_w_cities where 'corv.*' ~* any
(cities);
ohiocode | cities
----------+--------
(0 rows)
or_gis=# select * from quads_w_cities where 'Corv.*' ~* any
(cities);
ohiocode | cities
----------+--------
(0 rows)
or_gis=# select * from quads_w_cities where '.*Corv.*' ~* any
(cities);
ohiocode | cities
----------+--------
(0 rows)
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Nolan | 2007-01-20 22:52:07 | More grist for the PostgreSQL vs MySQL mill |
Previous Message | Josh Williams | 2007-01-20 21:12:41 | Re: Alter definition of a column |