Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Obtain only first 6 characters in a column of all rows in the table?

Re: Obtain only first 6 characters in a column of all rows in the table?

From: Oleg Kuzmin <kuzmin_at_hotmail.com>
Date: 2000/07/19
Message-ID: <snclp3du6tt90@corp.supernews.com>#1/1

Maggie,

If you want to use only first 6 characters of a column, you should use SUBSTR function.

The syntax is the following:
SUBSTR(column_name, start, length)

In your case it is going to be:
SELECT SUBSTR(COLUMN_A, 1, 4)
FROM PROD
WHERE SUBSTR(COLUMN_A, 1, 4) IN
(SELECT COLUMN_B
FROM SALE); Function RTRIM works completely different. It trims from the right side of a string a character or a set of characters specified, so it wouldn't be exactly what you want.

Oleg

Maggie <maggiezhou_at_hotmail.com> wrote in message news:8l5ir4$j39$1_at_web1.cup.hp.com...
> If I only want to use first 6 characters in one column A to match the
 other
> column B with only 6 characters, can I still use RTRIM? However, I know
> the RTRIM is single row function. Hence, I am not sure whether I could
> run the following? Or do you have a correct way to implement this
> selection?
>
> Table prod: columnA varchar2(10)
> Table sale: colunmB varchar2(6)
>
> select RTRIM( columnA, 4) from prod where RTRIM( columnA, 4) in (select
> columnB from sale);
>
> Thanks.
> Maggie
>
>
Received on Wed Jul 19 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US