Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

substring in informix SQL?

3,446 views
Skip to first unread message

Todd Gibson

unread,
Oct 20, 1998, 3:00:00 AM10/20/98
to
Is there any way to get a substring in a SQL expression?
Something like:

SELECT address FROM customer WHERE client_id =
substring('XYZ-someid',5,10);

Thanks,
-TAG
Todd A. Gibson


Jonathan Leffler

unread,
Oct 20, 1998, 3:00:00 AM10/20/98
to

On Tue, 20 Oct 1998, Todd Gibson wrote:
> Is there any way to get a substring in a SQL expression?
> Something like:
>
> SELECT address FROM customer WHERE client_id =
> substring('XYZ-someid',5,10);

You can use the SUBSTR() function in 7.30.
Why would you be substringing a literal, though?

In earlier versions, you have to use (and in 7.30, you may use):

SELECT address FROM Customer
WHERE Client_id[5,15] = 'XYZ-someid';

Note that this version uses [start-index, stop-index] whereas the
function uses SUBSTR(source, start-index, length).

Yours,
Jonathan Leffler (jlef...@informix.com) #include <witticism.h>
Guardian of DBD::Informix v0.60 -- http://www.perl.com/CPAN
Informix IDN for D4GL & Linux -- http://www.informix.com/idn


Irineu Rocha

unread,
Oct 21, 1998, 3:00:00 AM10/21/98
to

Hi Todd,

try

SELECT address FROM customer WHERE client_id[5,10] = "XYZ-someid";

I hope this help,

Irineu

> ----------
> From: Todd Gibson[SMTP:tgi...@flatland.dimensional.com]
> Reply To: Todd Gibson
> Sent: Tuesday, October 20, 1998 2:23 PM
> To: inform...@iiug.org
> Subject: substring in informix SQL?


>
> Is there any way to get a substring in a SQL expression?
> Something like:
>
> SELECT address FROM customer WHERE client_id =
> substring('XYZ-someid',5,10);
>

0 new messages