lance@unigold.UUCP (Lance Ellinghouse) (10/26/90)
Is there a way to say something like the following in SQL (and in a view especially)? [NOT Embeded SQL as I want to do this in a VIEW] select * from this_table where this_var=substring(1,4,this_other_string); this would select only the 1-4 chars of this_other_string and be used in the test?? Please do not say RTFM since I don't have any real SQL books around and SCO does not include them with Ingres. :( Thanks, +-------------------------------------------+ |Lance Ellinghouse | |E-mail: lance@unigold.uucp | | lance@unigold.sr.com | | hermix!unigold!lance@anes.ucla.edu | +-------------------------------------------+
drack@titan.tsd.arlut.utexas.edu (Dave Rackley) (10/26/90)
In article <9@unigold.UUCP> lance@unigold.UUCP (Lance Ellinghouse) writes: > Is there a way to say something like the following in SQL (and in a view > especially)? [NOT Embeded SQL as I want to do this in a VIEW] > select * > from this_table > where this_var=substring(1,4,this_other_string); > this would select only the 1-4 chars of this_other_string and > be used in the test?? The Ingres command for this is: this_var = left(this_other_string,4) Ingres also has: right(that_other_string,n) It returns the right most n characters. Good luck. -- DISCLAIMER? I don't know anything 'bout any ol' disclaimer! +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+ | David Rackley | | | Applied Research Laboratories | Remember, you can tuna fish, | | The University of Texas | But you can't tuna piano! | | Austin, TX. 78758 | | +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
dberg@informix.com (David I. Berg) (10/26/90)
> Is there a way to say something like the following in SQL (and in a view > especially)? [NOT Embeded SQL as I want to do this in a VIEW] > > select * from this_table where this_var=substring(1,4,this_other_string); > The syntax is: ......where this_var = this_other_string[1,4] David Berg
kho@joplin.mpr.ca (Peter Kho) (10/31/90)
To: lance@unigold.UUCP Subject: Re: substrings ??? Newsgroups: comp.databases In-Reply-To: <9@unigold.UUCP> Organization: Microtel Pacific Research Ltd., Burnaby, B.C., Canada Cc: Bcc: In article <9@unigold.UUCP> you write: >Is there a way to say something like the following in SQL (and in a view >especially)? [NOT Embeded SQL as I want to do this in a VIEW] > >select * >from this_table >where this_var=substring(1,4,this_other_string); > >this would select only the 1-4 chars of this_other_string and >be used in the test?? > >Please do not say RTFM since I don't have any real SQL books around >and SCO does not include them with Ingres. :( > Yes, it's pretty easy Using Ingres left and right functions as follows: select * from table where column = left(string,3) left (string, len) and right (string, len). Using a combination of lefts and rights, you can extract substrings of any length from any offset as follows: left(right(string, size(string) - 4), 5) ---> substring of 5 characters starting at character 5. Oracle provides a substring function as substr(string, offset, len). Have fun.