Re: Fetch array elements
Fred Toussi <[email protected]> Mon, 14 Dec 2015 14:18:00 +0000
| Newsgroups | gmane.comp.java.hsqldb.user |
|---|---|
| Message-ID | <1450102680.3269792.466918769.4BBEAD44@webmail.messagingengine.com> |
You can access elements of any array with the normal syntax select REGEXP_SUBSTRING_ARRAY( IP', '\d+')[1] ... You may be able to use a WITH subquery to populate the array only once. WITH SELECT IP, REGEXP_SUBSTRING_ARRAY( IP', '\d+') FROM IP_LOG AS IPVALS(IP, IPARRAY) SELECT IPARRAY[1], IPARRAY[2], CARDINALITY(IPARRAY) ... FROM IPVALS On Mon, Dec 14, 2015, at 11:52, Andreas Säger wrote: > Hello, > > Is it possible to get a single element returned by function > REGEXP_SUBSTRING_ARRAY? > > SELECT IP, > CARDINALITY(REGEXP_SUBSTRING_ARRAY( IP, '\d+')) AS "CARDINALITY" > FROM IP_LOG > > For any valid IPv4 address, the above query returns 4. I'd like to > access the 1st, second, third or 4th element in SQL. > > Thanks, > Andreas > > > ------------------------------------------------------------------------------ > _______________________________________________ > Hsqldb-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/hsqldb-user ------------------------------------------------------------------------------